웹프로그래밍

Global It Leader!!


PHP


 
 

php 로 openssl 만들기

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 4,316회 작성일 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 목록
번호 제목 글쓴이 조회 날짜
52 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3102 09-21
51 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3130 08-29
50 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3076 08-06
49 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3443 01-04
48 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3350 06-23
47 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3246 04-07
46 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5313 03-19
45 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3306 09-29
44 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4010 06-25
43 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3588 11-11
42 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3896 07-01
41 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4647 05-21
40 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4498 08-19
39 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3980 01-23
38 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4250 01-21
37 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4094 01-18
36 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4260 01-18
35 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3848 08-28
34 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3967 04-11
33 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4707 09-19