웹프로그래밍

Global It Leader!!


PHP


 
 

php 로 openssl 만들기

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 4,135회 작성일 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
);
?>

댓글목록

등록된 댓글이 없습니다.

전체 80
게시물 검색
PHP 목록
번호 제목 글쓴이 조회 날짜
60 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4897 03-10
59 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4859 03-19
58 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4753 04-22
57 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4730 09-14
56 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4681 02-11
55 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4602 03-10
54 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4496 09-19
53 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4486 02-29
52 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4432 04-22
51 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4409 05-21
50 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4388 04-22
49 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4290 08-19
48 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4222 03-04
47 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4188 04-07
46 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4180 03-21
열람중 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4136 08-17
44 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4047 01-18
43 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3955 10-19
42 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3952 01-21
41 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3876 01-18