happy Mom ——php mysqli DES加密

來源:互聯網
上載者:User

標籤:nbsp   vax   php   his   rate   enc   ring   外賣   資料庫   

  未來女:喜歡電影,喜歡讀書,有個小夢想是做個導演,導一部自己喜歡的片子。吃素多一點,好吃的肉也挺能吃,最喜歡的菜是糖醋排骨,可樂雞翅喜歡甜食。不喜歡吃外賣,喜歡家的感覺。喜歡傳輸速率曼和讓雷諾。

  難道她是上天派來的?OMG

  看完《愛你就像愛生命》這本書,真的看出小波哥很有才,跟小波哥比起來,我唯一拿的出手的可能就是我比他的顏值了。想起一句話,人不是因為美麗而可愛,而是因為可愛而美麗。所以我對我的要求是,繼續修鍊吧。

  今天被php的mysqli資料庫連接和查詢,弄的頭好頭疼。有個查詢$conn->query($sql);返回總是false。額,我命名用過這種查詢一模一樣,那個就好使。看來又被針對了。等解決了放上來。

  分享這個java可加密可解密的程式,親自用過,不能用預設的jdk,否則有報錯。

 1 import java.io.IOException;   2 import java.security.SecureRandom;   3 import javax.crypto.Cipher;   4 import javax.crypto.SecretKey;   5 import javax.crypto.SecretKeyFactory;   6 import javax.crypto.spec.DESKeySpec;   7 import sun.misc.BASE64Decoder;   8 import sun.misc.BASE64Encoder;   9 public class Des {  10   11     private byte[] desKey;  12   13     public Des(String desKey) {  14         this.desKey = desKey.getBytes();  15     }  16   17     public byte[] desEncrypt(byte[] plainText) throws Exception {  18         SecureRandom sr = new SecureRandom();  19         byte rawKeyData[] = desKey;  20         DESKeySpec dks = new DESKeySpec(rawKeyData);  21         SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");  22         SecretKey key = keyFactory.generateSecret(dks);  23         Cipher cipher = Cipher.getInstance("DES");  24         cipher.init(Cipher.ENCRYPT_MODE, key, sr);  25         byte data[] = plainText;  26         byte encryptedData[] = cipher.doFinal(data);  27         return encryptedData;  28     }  29   30     public byte[] desDecrypt(byte[] encryptText) throws Exception {  31         SecureRandom sr = new SecureRandom();  32         byte rawKeyData[] = desKey;  33         DESKeySpec dks = new DESKeySpec(rawKeyData);  34         SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");  35         SecretKey key = keyFactory.generateSecret(dks);  36         Cipher cipher = Cipher.getInstance("DES");  37         cipher.init(Cipher.DECRYPT_MODE, key, sr);  38         byte encryptedData[] = encryptText;  39         byte decryptedData[] = cipher.doFinal(encryptedData);  40         return decryptedData;  41     }  42   43     public String encrypt(String input) throws Exception {  44         return base64Encode(desEncrypt(input.getBytes()));  45     }  46   47     public String decrypt(String input) throws Exception {  48         byte[] result = base64Decode(input);  49         return new String(desDecrypt(result));  50     }  51   52     public static String base64Encode(byte[] s) {  53         if (s == null)  54             return null;  55         BASE64Encoder b = new sun.misc.BASE64Encoder();  56         return b.encode(s);  57     }  58   59     public static byte[] base64Decode(String s) throws IOException {  60         if (s == null)  61             return null;  62         BASE64Decoder decoder = new BASE64Decoder();  63         byte[] b = decoder.decodeBuffer(s);  64         return b;  65     }  66   67     public static void main(String[] args) throws Exception {  68         String key = "abcdefgh";  69         String input = "a";  70         Des crypt = new Des(key);  71         System.out.println("Encode:" + crypt.encrypt(input));  72         System.out.println("Decode:" + crypt.decrypt(crypt.encrypt(input)));  73     }  74 }  

 

 

  今天是媽媽的生日,我很感謝她樹立了我的三觀,希望她能在今後的每一天都過得開心,過得幸福。

  所以今天冰心的《寫給母親的詩》送給她

  母親,好久以來

  就想為你寫一首詩

  但寫了好多次

  還是沒有寫好

  母親,為你寫的這首詩

  我不知道該怎樣開頭

  不知道該怎樣結尾

  也不知道該寫些什麼

  就像兒時面對你嚴厲的巴掌

  我不知道是該勇敢接受

  還是該選擇逃避

  母親,今夜我又想起了你

  我決定還是要為你寫一首詩

  哪怕寫得不好

  哪怕遠在老家的你

  永遠也讀不到……

  母親,

  倘若你夢中看見一隻很小的白船兒,

  不要驚訝他無端入夢。

  這是你至愛的女兒(兒子左)含著淚疊的,

  萬水千山,

  求他載著她的愛和悲哀歸去。

  

 

happy Mom ——php mysqli DES加密

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.