Dasar String encoding / decoding fungsi
Dikirim oleh: bumiayucyber
fungsi:
Ini adalah dasar string yang encoding / decoding fungsi saya dikembangkan untuk digunakan di flat-file database. Mereka menawarkan keamanan terbatas untuk melindungi data sensitif dari yang dilihat.
penggunaan:..............................................................................................................................
<php encode ($ string, $ kunci);??> untuk mengkodekan.
<php decode ($ string, $ kunci);??> untuk memecahkan kode.
kode:........................................................................................................................................
<? php
fungsi encode ($ string, $ key) {
$ key = sha1 ($ kunci);
$ strlen = strlen ($ string);
$ keyLen = strlen ($ kunci);
for ($ i = 0; $ i <$ strlen; $ i + +) {
$ ordStr = Ord (substr ($ string, $ i, 1));
if ($ j == $ keyLen) {$ j = 0;}
$ ordKey = Ord (substr ($ key, $ j, 1));
$ j + +;
$ hash .= strrev (base_convert (dechex ($ ordStr + $ ordKey), 16,36));
}
return $ hash;
}
fungsi decode ($ string, $ key) {
$ key = sha1 ($ kunci);
$ strlen = strlen ($ string);
$ keyLen = strlen ($ kunci);
for ($ i = 0; $ i <$ strlen; $ i + = 2) {
$ ordStr = hexdec (base_convert (strrev (substr ($ string, $ i, 2)), 36,16));
if ($ j == $ keyLen) {$ j = 0;}
$ ordKey = Ord (substr ($ key, $ j, 1));
$ j + +;
hash $ .= chr ($ ordStr - $ ordKey);
}
return $ hash;
}
?>
Contoh # 1:
encode:
<php echo mengkodekan ("Silakan Encode Aku!", "Ini adalah kunci");??>
hasil:
p3e4e4241674d2r4m4i5o464a4f2p3k5c2
decode:
<php echo decode ("p3e4e4241674d2r4m4i5o464a4f2p3k5c2", "Ini adalah kunci");??>
hasil:
Silahkan Encode Me!
Contoh # 2:
encode:
<php echo mengkodekan ("Silakan Encode Aku!", "A New Key");??>
hasil:
t3t5e434q494f2m4s5j5w544b4d2m3k5i2
decode:
<php echo decode ("t3t5e434q494f2m4s5j5w544b4d2m3k5i2", "A New Key");??>
Dikirim oleh: bumiayucyber
fungsi:
Ini adalah dasar string yang encoding / decoding fungsi saya dikembangkan untuk digunakan di flat-file database. Mereka menawarkan keamanan terbatas untuk melindungi data sensitif dari yang dilihat.
penggunaan:..............................................................................................................................
<php encode ($ string, $ kunci);??> untuk mengkodekan.
<php decode ($ string, $ kunci);??> untuk memecahkan kode.
kode:........................................................................................................................................
<? php
fungsi encode ($ string, $ key) {
$ key = sha1 ($ kunci);
$ strlen = strlen ($ string);
$ keyLen = strlen ($ kunci);
for ($ i = 0; $ i <$ strlen; $ i + +) {
$ ordStr = Ord (substr ($ string, $ i, 1));
if ($ j == $ keyLen) {$ j = 0;}
$ ordKey = Ord (substr ($ key, $ j, 1));
$ j + +;
$ hash .= strrev (base_convert (dechex ($ ordStr + $ ordKey), 16,36));
}
return $ hash;
}
fungsi decode ($ string, $ key) {
$ key = sha1 ($ kunci);
$ strlen = strlen ($ string);
$ keyLen = strlen ($ kunci);
for ($ i = 0; $ i <$ strlen; $ i + = 2) {
$ ordStr = hexdec (base_convert (strrev (substr ($ string, $ i, 2)), 36,16));
if ($ j == $ keyLen) {$ j = 0;}
$ ordKey = Ord (substr ($ key, $ j, 1));
$ j + +;
hash $ .= chr ($ ordStr - $ ordKey);
}
return $ hash;
}
?>
Contoh # 1:
encode:
<php echo mengkodekan ("Silakan Encode Aku!", "Ini adalah kunci");??>
hasil:
p3e4e4241674d2r4m4i5o464a4f2p3k5c2
decode:
<php echo decode ("p3e4e4241674d2r4m4i5o464a4f2p3k5c2", "Ini adalah kunci");??>
hasil:
Silahkan Encode Me!
Contoh # 2:
encode:
<php echo mengkodekan ("Silakan Encode Aku!", "A New Key");??>
hasil:
t3t5e434q494f2m4s5j5w544b4d2m3k5i2
decode:
<php echo decode ("t3t5e434q494f2m4s5j5w544b4d2m3k5i2", "A New Key");??>
0 komentar:
Speak up your mind
Tell us what you're thinking... !