標籤: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加密