ããè¿é以å符串123456为ä¾åï¼å®çmd5å¯æå¼ä¸ºï¼e10adc3949ba59abbe56e057f20f883e
ããè¿é以1.txt为éè¦è¢«å å¯çæ件ã
ããä¸ã ç¨oppnssl md5 å å¯å符串åæ件çæ¹æ³ã
ãã1. oppnssl md5 å å¯å符串çæ¹æ³
ããa.æå¨è¾å
¥å½ä»¤åè¿ç¨å¦ä¸ï¼
ãã#openssl //å¨ç»ç«¯ä¸è¾å
¥opensslåå车ã
ããOpenSSL> md5 //è¾å
¥md5åå车
ãã123456 //æ¥çè¾å
¥123456ï¼ä¸è¦è¾å
¥å车ãç¶åæ3次ctrl+dã
ãã123456e10adc3949ba59abbe56e057f20f883e //123456åé¢çå°±æ¯å¯æäº
ãã解éï¼ä¸ºä½å¨è¾å
¥123456åä¸å车å¢ï¼
ããæ¯å 为opensslé»è®¤ä¼æå车符å½åè¦å å¯çå符串ä¸çä¸ä¸ªå符ï¼æ以å¾å°çç»æä¸åãå¦æä½ è¾å
¥123456åå车ï¼å¨æ2次ctrl+dãå¾å°çç»ææ¯ï¼
ããOpenSSL> md5
ãã123456
ããf447b20a7fcbf53a5d5be013ea0b15af //å 为opensslä¸å¿½ç¥å车符导è´ç
ããb.æè
ç´æ¥ç¨ç®¡éå½ä»¤
ãã# echo -n 123456 | openssl md5 //å¿
é¡»è¦æ-nåæ°ï¼å¦åå°±ä¸æ¯è¿ä¸ªç»æäºã
ããe10adc3949ba59abbe56e057f20f883e
ãã解éï¼ä¸ºä½è¦å -nè¿ä¸ªåæ°ï¼
ãã-n就表示ä¸è¾å
¥å车符ï¼è¿æ ·æè½å¾å°æ£ç¡®çç»æãå¦æä½ ä¸å -nï¼é£ä¹ç»æååé¢è¯´çä¸æ ·ä¸ºï¼
ããf447b20a7fcbf53a5d5be013ea0b15af //å 为opensslä¸å¿½ç¥å车符导è´ç
ãã2.ç¨opensslå å¯æ件ã
ãã#openssl md 5 -in 1.txt
ãã
ãã##################################################3
ããOpensslå
¶ä»ç¸å
³å å¯çå½ä»¤åæ°ï¼å¼èªï¼å®ç¨å½ä»¤ï¼å©ç¨opensslè¿è¡BASE64ç¼ç 解ç ãmd5/sha1æè¦ãAES/DES3å å¯è§£å¯ æ¶è
ããä¸. å©ç¨opensslå½ä»¤è¿è¡BASE64ç¼ç 解ç ï¼base64 encode/decodeï¼
ãã1. BASE64ç¼ç å½ä»¤
ãã对å符串âabcâè¿è¡base64ç¼ç ï¼
ãã# echo abc | openssl base64
ããYWJjCg== ï¼ç¼ç ç»æï¼
ããå¦æ对ä¸ä¸ªæ件è¿è¡base64ç¼ç ï¼æ件åt.txtï¼ï¼
ãã# openssl base64 -in t.txt
ãã2. BASE64解ç å½ä»¤
ããæ±base64åçå符串âYWJjCg==âçåæï¼
ãã# echo YWJjCg== | openssl base64 -d
ããabc ï¼è§£ç ç»æï¼
ããå¦æ对ä¸ä¸ªæ件è¿è¡base64解ç ï¼æ件åt.base64ï¼ï¼
ãã# openssl base64 -d -in t.base64
ããäº. å©ç¨opensslå½ä»¤è¿è¡md5/sha1æè¦ï¼digestï¼
ãã1. 对å符串âabcâè¿è¡md5æè¦è®¡ç®ï¼echo abc | openssl md5
ããè¥å¯¹ææ件è¿è¡md5æè¦è®¡ç®ï¼openssl md5 -in t.txt
ãã2. 对å符串âabcâè¿è¡sha1æè¦è®¡ç®ï¼echo abc | openssl sha1
ããè¥å¯¹ææ件è¿è¡sha1æè¦è®¡ç®ï¼openssl sha1 -in t.txt
ããä¸. å©ç¨opensslå½ä»¤è¿è¡AES/DES3å å¯è§£å¯ï¼AES/DES3 encrypt/decryptï¼
ãã对å符串âabcâè¿è¡aeså å¯ï¼ä½¿ç¨å¯é¥123ï¼è¾åºç»æ以base64ç¼ç æ ¼å¼ç»åºï¼
ãã# echo abc | openssl aes-128-cbc -k 123 -base64
ããU2FsdGVkX18ynIbzARm15nG/JA2dhN4mtiotwD7jt4g= ï¼ç»æï¼
ãã对以ä¸ç»æè¿è¡è§£å¯å¤çï¼
ãã# echo U2FsdGVkX18ynIbzARm15nG/JA2dhN4mtiotwD7jt4g= | openssl aes-128-cbc -d -k 123 -base64
ããabc ï¼ç»æï¼
ããè¥è¦ä»æ件éååæï¼å¯æï¼è¿è¡å å¯ï¼è§£å¯ï¼ï¼åªè¦æå® -in åæ°æåæ件åå°±å¯ä»¥äºã
ããè¿è¡des3å 解å¯ï¼åªè¦æå½ä»¤ä¸çaes-128-cbcæ¢ædes3å°±å¯ä»¥äºã
ãã注ï¼åªè¦å©ç¨openssl helpå°±å¯ä»¥çå°æ´å¤çå®å
¨ç®æ³äºã
ãã###############################################
ãã
ããäºã å©ç¨phpçmd5å½æ°å å¯å符串
ãã#touch a.php //å建a.phpæ件
ãã#vi a.php //ç¨vi ç¼è¾a.phpæ件
ããå°<?php echo md5(123456); ?>è¾å
¥è¿å»åä¿å
ãã#php a.php //è¿è¡a.phpæ件
ããæ¾ç¤ºï¼e10adc3949ba59abbe56e057f20f883e
ããä¸ã å©ç¨md5sumå½ä»¤
ããA.å¨linuxæUnixä¸ï¼md5sumæ¯ç¨æ¥è®¡ç®åæ ¡éªæ件æ¥ææè¦çå·¥å
·ç¨åºãä¸è¬æ¥è¯´ï¼å®è£
äºLinuxåï¼å°±ä¼æmd5sumè¿ä¸ªå·¥å
·ï¼ç´æ¥å¨å½ä»¤è¡ç»ç«¯ç´æ¥è¿è¡ãå¯ä»¥ç¨ä¸é¢çå½ä»¤æ¥è·åmd5sumå½ä»¤å¸®å© man md5sum
ãã#md5sum âhelp
ããæ个æ示ï¼âWith no FILE, or when FILE is -, read standard input.âç¿»è¯è¿æ¥å°±æ¯âå¦æ没æè¾å
¥æ件é项æè
æ件é项为 - ï¼åä»æ ç 读åè¾å
¥å
容âï¼å³å¯ä»¥ç´æ¥ä»é®ç读åå符串æ¥å å¯ã
ããå©ç¨md5sumå å¯å符串çæ¹æ³
ãã# md5sum //ç¶åå车
ãã123456 //è¾å
¥123456.ç¶åæ两次ctrl+d.
ããæ¾ç¤ºï¼
ãã123456e10adc3949ba59abbe56e057f20f883e 红è²ä»£è¡¨å å¯åçå¼
ããè¿å¯ä»¥ç¨ç®¡éå½ä»¤ï¼
ãã#echo -n '123123' | md5sum
ãã
ããæè
åæmd5å å¯èæ¬ï¼ååå«md5.shï¼
ããå°ä»¥ä¸å
容å¤å¶è¿èæ¬éï¼
ãã#!/bin/bash
ããecho -n $1 | md5sum | awk '{print $1}'
ãã
ããä¿ååï¼ç»èæ¬æ§è¡æéã
ãã#sh md5.sh 123456
ããæ¾ç¤ºï¼e10adc3949ba59abbe56e057f20f883e
ããB.å
¶å®ä¹å¯ä»¥å°ææ¬æ¾å
¥ææ¬æ件ï¼ç¶åç¨md5sum å å¯æ¹ææ¬ï¼ä¹å¯ä»¥å¾å°å符串å å¯çå¼ãè¿ç¨å¦ä¸ï¼
ãã#touch a.txt
ãã#echo -n 123456 > a.txt //å°123456åè¿ææ¬æ件ï¼ä¸è½ä¸¢äº ânåæ°ï¼é¿å
å车符干æ°
ãã#md5sum a.txt
ããæ¾ç¤ºï¼e10adc3949ba59abbe56e057f20f883e a.txt
ãã
ããctrl+dæ两个å«ä¹ï¼
ããä¸æ¯åç¨åºåéæ件è¾å
¥ç»æ符EOFã
ããäºæ¯åç¨åºåéexitéåºæ令ãç¨åºæ¶å°ä¿¡å·åå
·ä½å¨ä½æ¯ç»æè¾å
¥ãç¶åçå¾
ï¼è¿æ¯ç´æ¥éåºï¼é£å°±è¦ç该ç¨åºæè·ä¿¡å·åæ¯å¦ä½æä½çäºã
ããmd5sumå±äºç¬¬ä¸ä¸ªå«ä¹ã两次strl+däºï¼ç¬¬ä¸æ¬¡è¯»åEOFæ令ï¼å次æè·å°±ä¼å½æexitæ令ãèshellä¸ç±»çç¨åºï¼ä¼ç´æ¥æctrl+d解æ为éåºæ令ã
温馨提示:答案为网友推荐,仅供参考