웹프로그래밍

Global It Leader!!


PHP


 
 

php 로 openssl 만들기

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 4,320회 작성일 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 목록
번호 제목 글쓴이 조회 날짜
72 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5195 04-22
71 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5102 03-10
70 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4974 09-14
69 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4958 04-22
68 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4949 02-11
67 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4796 03-10
66 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4708 09-19
65 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4705 02-29
64 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4674 04-22
63 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4655 05-21
62 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4614 04-22
61 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4502 08-19
60 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4460 10-19
59 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4438 12-31
58 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4426 03-04
57 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4389 04-07
56 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4383 03-21
열람중 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4321 08-17
54 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4262 01-18
53 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4253 01-21