웹프로그래밍

Global It Leader!!


PHP


 
 

php 로 openssl 만들기

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 4,333회 작성일 12-08-17 13:24

본문

<?php
/*-----------------------------------------------------------*
 * AES: openSSL (PHP) implementation                         *
 *-----------------------------------------------------------*/
 
 # init
 
$keySizeInBits = 128
;
 
$keySize = ($keySizeInBits / 8
);

 
# get method
 
$method = getMethod($keySize, "ofb"
);

 
# get the cipher key
 
$salt = openssl_random_pseudo_bytes(8
);
 
$key = pbkdf2("Secret Passphrase", $salt, 1000, $keySize
);

/*-----------------------------------------------------------*
 * ENCRYPT: AES 128 bit, OFB                                 *
 *-----------------------------------------------------------*/
 # get iv
 
$iv = openssl_random_pseudo_bytes(16
);
 
$iv64 = base64_encode($iv
);

 
# do encryption
 
$raw = false;
// true returns raw bytes, false returns base64
 
$ciphertext = openssl_encrypt("plaintext", $method, $key, $raw, $iv
);

/*-----------------------------------------------------------*
 * DECRYPT: AES 128 bit, OFB                                 *
 *-----------------------------------------------------------*/
 # get the IV
 
$iv = base64_decode($iv64
);

 
# do decryption
 
$plain = openssl_decrypt($ciphertext, $method, $key, $raw, $iv
);
?>

댓글목록

등록된 댓글이 없습니다.

전체 92
게시물 검색
PHP 목록
번호 제목 글쓴이 조회 날짜
32 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4987 09-14
열람중 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4334 08-17
30 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5601 06-08
29 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6520 04-22
28 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5210 04-22
27 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4687 04-22
26 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4628 04-22
25 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4972 04-22
24 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6617 04-20
23 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4405 04-07
22 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5773 03-21
21 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4398 03-21
20 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5113 03-10
19 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4811 03-10
18 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4437 03-04
17 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4717 02-29
16 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4960 02-11
15 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5688 11-11
14 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7252 05-19
13 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6803 05-10