PHP 클래스 CI_Encrypt, TastyIgniter

Provides two-way keyed encoding using XOR Hashing and Mcrypt
저자: ExpressionEngine Dev Team
파일 보기 프로젝트 열기: tastyigniter/tastyigniter 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$encryption_key string Reference to the user's encryption key

보호된 프로퍼티들

프로퍼티 타입 설명
$_hash_type string Type of hash operation
$_mcrypt_cipher string Current cipher to be used with mcrypt
$_mcrypt_exists boolean Flag for the existence of mcrypt
$_mcrypt_mode integer Method for encrypting/decrypting data

공개 메소드들

메소드 설명
__construct ( ) : void Initialize Encryption class
decode ( $string, $key = '' ) : string Decode
encode ( $string, $key = '' ) : string Encode
encode_from_legacy ( $string, $legacy_mode = MCRYPT_MODE_ECB, $key = '' ) : string Encode from Legacy
get_key ( $key = '' ) : string Fetch the encryption key
hash ( $str ) : string Hash encode a string
mcrypt_decode ( $data, $key ) : string Decrypt using Mcrypt
mcrypt_encode ( $data, $key ) : string Encrypt using Mcrypt
set_cipher ( $cipher ) : CI_Encrypt Set the Mcrypt Cipher
set_hash ( $type = 'sha1' ) : void Set the Hash type
set_key ( $key = '' ) : CI_Encrypt Set the encryption key
set_mode ( $mode ) : CI_Encrypt Set the Mcrypt Mode

보호된 메소드들

메소드 설명
_add_cipher_noise ( $data, $key ) : string Adds permuted noise to the IV + encrypted data to protect against Man-in-the-middle attacks on CBC mode ciphers http://www.ciphersbyritter.com/GLOSSARY.HTM#IV
_get_cipher ( ) : integer Get Mcrypt cipher Value
_get_mode ( ) : integer Get Mcrypt Mode Value
_remove_cipher_noise ( string $data, string $key ) : string Removes permuted noise from the IV + encrypted data, reversing _add_cipher_noise()
_xor_decode ( $string, $key ) : string XOR Decode
_xor_merge ( $string, $key ) : string XOR key + string Combiner

메소드 상세

__construct() 공개 메소드

Initialize Encryption class
public __construct ( ) : void
리턴 void

_add_cipher_noise() 보호된 메소드

Adds permuted noise to the IV + encrypted data to protect against Man-in-the-middle attacks on CBC mode ciphers http://www.ciphersbyritter.com/GLOSSARY.HTM#IV
protected _add_cipher_noise ( $data, $key ) : string
리턴 string

_get_cipher() 보호된 메소드

Get Mcrypt cipher Value
protected _get_cipher ( ) : integer
리턴 integer

_get_mode() 보호된 메소드

Get Mcrypt Mode Value
protected _get_mode ( ) : integer
리턴 integer

_remove_cipher_noise() 보호된 메소드

Function description
protected _remove_cipher_noise ( string $data, string $key ) : string
$data string
$key string
리턴 string

_xor_decode() 보호된 메소드

Takes an encoded string and key as input and generates the plain-text original message
protected _xor_decode ( $string, $key ) : string
리턴 string

_xor_merge() 보호된 메소드

Takes a string and key as input and computes the difference using XOR
protected _xor_merge ( $string, $key ) : string
리턴 string

decode() 공개 메소드

Reverses the above process
public decode ( $string, $key = '' ) : string
리턴 string

encode() 공개 메소드

Encodes the message string using bitwise XOR encoding. The key is combined with a random hash, and then it too gets converted using XOR. The whole thing is then run through mcrypt using the randomized key. The end result is a double-encrypted message string that is randomized with each call to this function, even if the supplied message and key are the same.
public encode ( $string, $key = '' ) : string
리턴 string

encode_from_legacy() 공개 메소드

Takes an encoded string from the original Encryption class algorithms and returns a newly encoded string using the improved method added in 2.0.0 This allows for backwards compatibility and a method to transition to the new encryption algorithms. For more details, see https://codeigniter.com/user_guide/installation/upgrade_200.html#encryption
public encode_from_legacy ( $string, $legacy_mode = MCRYPT_MODE_ECB, $key = '' ) : string
리턴 string

get_key() 공개 메소드

Returns it as MD5 in order to have an exact-length 128 bit key. Mcrypt is sensitive to keys that are not the correct length
public get_key ( $key = '' ) : string
리턴 string

hash() 공개 메소드

Hash encode a string
public hash ( $str ) : string
리턴 string

mcrypt_decode() 공개 메소드

Decrypt using Mcrypt
public mcrypt_decode ( $data, $key ) : string
리턴 string

mcrypt_encode() 공개 메소드

Encrypt using Mcrypt
public mcrypt_encode ( $data, $key ) : string
리턴 string

set_cipher() 공개 메소드

Set the Mcrypt Cipher
public set_cipher ( $cipher ) : CI_Encrypt
리턴 CI_Encrypt

set_hash() 공개 메소드

Set the Hash type
public set_hash ( $type = 'sha1' ) : void
리턴 void

set_key() 공개 메소드

Set the encryption key
public set_key ( $key = '' ) : CI_Encrypt
리턴 CI_Encrypt

set_mode() 공개 메소드

Set the Mcrypt Mode
public set_mode ( $mode ) : CI_Encrypt
리턴 CI_Encrypt

프로퍼티 상세

$_hash_type 보호되어 있는 프로퍼티

Type of hash operation
protected string $_hash_type
리턴 string

$_mcrypt_cipher 보호되어 있는 프로퍼티

Current cipher to be used with mcrypt
protected string $_mcrypt_cipher
리턴 string

$_mcrypt_exists 보호되어 있는 프로퍼티

Flag for the existence of mcrypt
protected bool $_mcrypt_exists
리턴 boolean

$_mcrypt_mode 보호되어 있는 프로퍼티

Method for encrypting/decrypting data
protected int $_mcrypt_mode
리턴 integer

$encryption_key 공개적으로 프로퍼티

Reference to the user's encryption key
public string $encryption_key
리턴 string