  | 
				VFP ·R¥ÎªÌªÀ°Ï ¥»°Q½×°Ï¬° Visual Foxpro ·R¥ÎªÌ¸gÅç¥æ¬yªº¦a¤è, ½Ð¦h¦h§Q¥Î"·j´M"ªº¥\¯à, ¥ý¬d¬Ý¬Ý¦³µL«e¨Ò¥i´`, ¦pªGÁÙ¦³¤£À´ªº¦Aµo°Ý. ³¡¥÷¥DÃD¦³ªþ¥[ÀÉ®×, ¶·¥ýµù¥U¦¨¬°ªÀ°Ï©~¥Á¤~¥i¥H¤U¸ü.   
				 | 
			 
		 
		 
	
		| ¤W¤@½g¥DÃD :: ¤U¤@½g¥DÃD   | 
	 
	
	
		| µoªí¤H | 
		¤º®e | 
	 
	
		jimmy987
 
 
  µù¥U®É¶¡: 2003-06-26 ¤å³¹: 33
 
  ²Ä 1 ¼Ó
  | 
		
			
				 µoªí©ó: ¬P´Á¤G ¤Q¤ë 24, 2023 12:22 pm    ¤å³¹¥DÃD: 3DES ¥[±K°ÝÃD, ¨D°ª¤âÀ°¦£¬Ý¬Ý | 
				     | 
			 
			
				
  | 
			 
			
				¤p§Ì³Ìªñ¦³¤@Ó3DES ¥[±K°ÝÃD, ¤£ª¾VFPn¦p¦ó¼g¤~·|¥¿½T
 
³o¬O¼t°Ó´£¨ÑªºC# µ{§Ç, n¦p¦ó¼g¦¨VFPµ{§Ç
 
Inputdata : ºÝ¥½¥æ©ö§Ç¸¹6½X+¯S©±¥N¸¹15½X+¥æ©ö¤é´Á8½X+ºÝ¥½¥N¸¹8½X+¥æ©ö®É¶¡6½X+¦¬³æ¦æ¥N½X3½X+©T©wÈ00¡C(¦@48 bytes) 
 
Inputdata :151726006868635311001202310191001500115172600600 (¦¹ÈngetBytes)
 
 
ÅçÃҰѼÆ:F1A81B8C69D4DB7FEBFCEE46985172DB  (¦¹ÈnHexToByte)
 
 
IV:FOCASAPI (¦¹ÈngetBytes)
 
 
¥[±K«áªºÈÂনHEX String:FF1B68F015357E86C877EA4D75ACB0A1C774ED26EF2670C4E40B65D2CDFE108E96E532F89FB911EAFB8EEFE7995BEC2E
 
 
3DES CBC µLPadding.
 
 
 
 
 
C#½d¨Òµ{¦¡½X¡G
 
 
 
string input = traceNumber + merchantId + localdate + terminalId + localtime + acqBank + "00"; 
 
byte[] b_input = System.Text.Encoding.UTF8.GetBytes(input);
 
byte[] iv = System.Text.Encoding.UTF8.GetBytes("FOCASAPI");
 
byte[] result =  TripleDEScrypto.Encrypt(b_input, HexToByte(key.Text), iv , CipherMode.CBC , PaddingMode.None); 
 
string termvericode = ToHexString(result); 
 
termvericode = termvericode.Substring(termvericode.Length -  ;
 
 
public static byte[] Encrypt(byte[] toEncrypt, byte[] Key, byte[] IV , CipherMode mode,PaddingMode padding) {
 
    try
 
         {
 
                TripleDESCryptoServiceProvider symcsp = new TripleDESCryptoServiceProvider();
 
                symcsp.Mode = mode;
 
                symcsp.Padding = padding;
 
                symcsp.Key = Key;
 
                if (mode != CipherMode.ECB)
 
                {
 
                    symcsp.IV = IV;
 
                }
 
                return Encrypt(toEncrypt, symcsp);
 
            }
 
 
            catch (CryptographicException e)
 
            {
 
                throw new Exception("TripleDEScrypto.Encrypt Error: " + e.Message, e);
 
            }
 
}
 
 
 
 
public static byte[] Encrypt(byte[] toEncrypt, SymmetricAlgorithm symcsp)
 
        {
 
            try
 
            {
 
                MemoryStream mStream = new MemoryStream();
 
                CryptoStream cStream = new CryptoStream(mStream, symcsp.CreateEncryptor(),
 
                    CryptoStreamMode.Write);
 
                cStream.Write(toEncrypt, 0, toEncrypt.Length);
 
                cStream.FlushFinalBlock();
 
                byte[] ret = mStream.ToArray();
 
                cStream.Close();
 
                mStream.Close();
 
                return ret;
 
            }
 
 
            catch (CryptographicException e)
 
            {
 
                throw new Exception("TripleDEScrypto.Encrypt Error: " + e.Message, e);
 
            }
 
        }
 
 
 
§Ú¼gªºVFPµ{§Ç¦p¤U, ¤£ª¾¿ù¦b¦ó³B:
 
°õ¦æ¤U±¨ç¼Æ¨DÈ:
 
? des3('151726006868635311001202310191001500115172600600','F1A81B8C69D4DB7FEBFCEE46985172DB','FOCASAPI',0,'cbc')
 
 
 
********
 
*3DES¥[±K, CBC ,ECB 
 
*lcdata=¥[±Kªº¦r¦ê
 
*lcpass=¥[±Kªºhashkey
 
*lciv=IVÈ
 
*lcPadding=PaddingÈ, ¤@¯ë¬°0
 
*lctype=¥[±K«¬ºA, cbc, ecb
 
*¦^¶Ç: 3desªº¥[±KÈ
 
********
 
FUNCTION DES3
 
LPARAMETERS lcdata,lcpass,lciv,lcPadding,lctype
 
 
IF TYPE('lcdata')<> 'C'
 
	MESSAGEBOX('¥[±Kªº¸ê®Æ¥²¶·¬°¦r¦ê')
 
	RETURN .F.
 
ENDIF 
 
IF TYPE('lcpass')<> 'C'
 
	MESSAGEBOX('¥[±Kªºhashkey¥²¶·¬°¦r¦ê')
 
	RETURN .F.
 
ENDIF 
 
IF TYPE('lciv')<> 'C'
 
	MESSAGEBOX('IV¥²¶·¬°¦r¦ê')
 
	RETURN .F.
 
ENDIF 
 
IF TYPE('lcPadding')<> 'N'
 
	lcPadding=0
 
ENDIF 
 
 
IF UPPER(lctype)='CBC' OR UPPER(lctype)='ECB'
 
ELSE
 
	MESSAGEBOX('¥[±K«¬ºA¤£¹ï, ¥²¶·¬°CBC©ÎECB',0+16,'¨t²Î³qª¾')
 
	RETURN .f.
 
ENDIF 
 
 
LOCAL loCrypt
 
LOCAL lcIvHex
 
LOCAL lcKeyHex
 
LOCAL lcEncStr
 
LOCAL lcDecStr
 
LOCAL crlf
 
crlf=CHR(13)+CHR(10)
 
 
 
**********
 
loCrypt = CreateObject('Chilkat_9_5_0.Crypt2')
 
 
* Specify 3DES for the encryption algorithm:
 
* «ü©w¥[±Kºâªk¬°3DES¡G 
 
loCrypt.CryptAlgorithm = "3des"
 
 
* CipherMode may be "ecb" or "cbc"
 
loCrypt.CipherMode = LOWER(lctype)	&&"cbc"
 
 
* KeyLength must be 192.  3DES is technically 168-bits;
 
* the most-significant bit of each key byte is a parity bit,
 
* so we must indicate a KeyLength of 192, which includes
 
* the parity bits.
 
loCrypt.KeyLength = 192
 
 
* The padding scheme determines the contents of the bytes
 
* that are added to pad the result to a multiple of the
 
* encryption algorithm's block size.  3DES has a block
 
* size of 8 bytes, so encrypted output is always
 
* a multiple of 8.
 
loCrypt.PaddingScheme = lcPadding
 
 
* EncodingMode specifies the encoding of the output for
 
* encryption, and the input for decryption.
 
* It may be "hex", "url", "base64", or "quoted-printable".
 
loCrypt.EncodingMode = "hex"
 
 
* An initialization vector is required if using CBC or CFB modes.
 
* ECB mode does not use an IV.
 
* The length of the IV is equal to the algorithm's block size.
 
* It is NOT equal to the length of the key.
 
lcIvHex = get_ascstr(lciv)
 
loCrypt.SetEncodedIV(lcIvHex,"hex")
 
 
* The secret key must equal the size of the key.  For 
 
* 3DES, the key must be 24 bytes (i.e. 192-bits).
 
 
lcKeyHex = hextobytes(lcpass)		
 
loCrypt.SetEncodedKey(lcKeyHex,"hex")
 
 
 
* Encrypt a string...
 
* The input string is 44 ANSI characters (i.e. 44 bytes), so
 
* the output should be 48 bytes (a multiple of  .
 
* Because the output is a hex string, it should
 
* be 96 characters long (2 chars per byte).
 
 
inputdata=get_ascstr(lcdata)
 
lcEncStr = loCrypt.EncryptStringENC(inputdata)
 
 
=STRTOfile('inputdata:'+lcdata+crlf,'c:\3des.txt',0)
 
=STRTOfile('inputdata getbytes value:'+inputdata+crlf,'c:\3des.txt',1)
 
 
=STRTOfile('lcKeyHex:'+lcpass+crlf,'c:\3des.txt',1)
 
=STRTOfile('lcKeyHex hextobytes:'+lcKeyHex+crlf,'c:\3des.txt',1)
 
 
=STRTOfile('IV:'+lciv+crlf,'c:\3des.txt',1)
 
=STRTOfile('IV getbytes value::'+lcIvHex+crlf,'c:\3des.txt',1)
 
 
=STRTOfile('¥[±K«áªºÈ:'+lcEncStr+crlf,'c:\3des.txt',1)
 
 
* Now decrypt:
 
* ²{¦b¸Ñ±K¡G 
 
lcDecStr = loCrypt.DecryptStringENC(lcEncStr)
 
? lcDecStr
 
=STRTOfile('¸Ñ±K«áªºÈ:'+lcDecStr+crlf,'c:\3des.txt',1)
 
 
RELEASE loCrypt
 
RETURN lcEncStr
 
 
 
**********************
 
*»¡©ú: ¤@Ó16¶i¦ì¦r¦êÂনbyte¼Æ¦r¦r¦ê
 
*°Ñ¼Æ: getstr1=nÂà´«ªº16¶i¦ì¦r¦ê
 
*ªð¦^: ¤@Ó10¶i¦ì½s½X¦r¦ê(¤j¼g)
 
*½d¨Ò: hextobytes('F1A81B8C69D4DB7FEBFCEE46985172DB')
 
*µ²ªG: 241168271401052122191272352522387015281114219
 
***********************
 
FUNCTION hextobytes
 
LPARAMETERS getstr1
 
LOCAL ret_str,ii,ii_end
 
IF TYPE('getstr1')<> 'C'
 
	RETURN ''
 
ENDIF 
 
ret_str=''
 
ii_end=LEN(getstr1)/2
 
FOR ii=0 TO ii_end-1
 
	ret_str=ret_str+TRANSFORM(hex2dec(SUBSTR(getstr1,ii*2+1,2)))
 
ENDFOR 
 
RETURN ret_str
 
 
 
***********************
 
*»¡©ú: ¤@Ó¦r¦êÂনbyte¼Æ¦r¦r¦ê
 
*°Ñ¼Æ: getstr1=nÂà´«ªº¦r¦ê
 
*ªð¦^: ¤@Ó10¶i¦ì½s½X¦r¦ê(¤j¼g)
 
*½d¨Ò: get_ascstr('this is qrcode')
 
*µ²ªG: 116104105115321051153211311499111100101
 
 
***********************
 
FUNCTION get_ascstr
 
LPARAMETERS getstr1
 
LOCAL ret_str,ii,ii_end
 
IF TYPE('getstr1')<> 'C'
 
	RETURN ''
 
ENDIF 
 
ret_str=''
 
ii_end=LEN(getstr1)
 
FOR ii=1 TO ii_end
 
	ret_str=ret_str+TRANSFORM(ASC(SUBSTR(getstr1,ii,1)))
 
ENDFOR 
 
RETURN ret_str
 
 
 
***************
 
*¤Q¤»¶i¨î->¤Q¶i¨îÂà´«¨ç¼Æ¡A
 
***************
 
FUNCTION hex2dec
 
PARAMETERS hexnum
 
 
STORE 0 TO decnum
 
STORE '' TO tempnum
 
IF LEN(ALLTRIM(hexnum)) < 4
 
   hexnum = PADL(hexnum, 4, '0')
 
ENDIF ( LEN(ALLTRIM(hexnum)) < 4 )
 
STORE LEN(hexnum)-1 TO indx
 
 
FOR i = 1 TO LEN(hexnum)
 
   DO CASE
 
      CASE SUBSTR(UPPER(hexnum), i, 1) == "F"
 
         tempnum = '15'
 
      CASE SUBSTR(UPPER(hexnum), i, 1) == "E"
 
         tempnum = '14'
 
      CASE SUBSTR(UPPER(hexnum), i, 1) == "D"
 
         tempnum = '13'
 
      CASE SUBSTR(UPPER(hexnum), i, 1) == "C"
 
         tempnum = '12'
 
      CASE SUBSTR(UPPER(hexnum), i, 1) == "B"
 
         tempnum = '11'
 
      CASE SUBSTR(UPPER(hexnum), i, 1) == "A"
 
         tempnum = '10'
 
      OTHERWISE
 
         tempnum = SUBSTR(hexnum, i, 1)
 
   ENDCASE
 
   decnum = decnum + (VAL(tempnum) * (16^indx))
 
   indx = indx - 1
 
ENDFOR ( i )
 
RETURN decnum
 
 
 
±o¨ìµ²ªG¬°:
 
inputdata:151726006868635311001202310191001500115172600600
 
inputdata getbytes value:495349555054484854565456545153514949484849504850514948495749484849534848494953495550544848544848
 
lcKeyHex:F1A81B8C69D4DB7FEBFCEE46985172DB
 
lcKeyHex hextobytes:241168271401052122191272352522387015281114219
 
IV:FOCASAPI
 
IV getbytes value::7079676583658073
 
¥[±K«áªºÈ:D9D1F5BBCF2202B4D00154937DAEAD4B31BCC48ACE13B39C706565F0DCB1B9650978AC83EE3E2B95BAAA2716B3DB4CF92CC90A334106506FE435B380C5EF80ADA7F05D952B327FEC4903AA50CC0EABBF621FB83A1EF827A585E0AE86BD501E49BAF0A6FF04B1CF5D
 
¸Ñ±K«áªºÈ:495349555054484854565456545153514949484849504850514948495749484849534848494953495550544848544848 | 
			 
		  | 
	 
	
		| ¦^³»ºÝ | 
		 | 
	 
	
		  | 
	 
	
		jimmy987
 
 
  µù¥U®É¶¡: 2003-06-26 ¤å³¹: 33
 
  ²Ä 2 ¼Ó
  | 
		
			
				 µoªí©ó: ¬P´Á¤T ¤Q¤ë 25, 2023 1:46 pm    ¤å³¹¥DÃD: ¦³¿³½ì±N¤WzC#µ{¦¡,»s§@¦¨FOXPRO¥i¥HŪ¨úªºDLL, ¥i¥H³ø»ùµ¹§Ú | 
				     | 
			 
			
				
  | 
			 
			
				¦³¿³½ì±N¤WzC#µ{¦¡,»s§@¦¨FOXPRO¥i¥HŪ¨úªºDLL, ¥i¥H³ø»ùµ¹§Ú
 
§ÚªºEMAIL:trh28525@yahoo,com.tw 
 
«H¤¤µ¹§Ú¤@Ó³ø»ù¤Î¦h¤[¥i¥H§¹¦¨®É¶¡¤ÎÁpµ¸¤è¦¡, ÁÂÁÂ..
 
 
¦bfoxpro ¿é¤J¨ç¼Æ¦p: t3des(Inputdata ,KEY,IV,0,'cbc')
 
                     t3des('151726006868635311001202310191001500115172600600','F1A81B8C69D4DB7FEBFCEE46985172DB','FOCASAPI',0,'cbc')
 
·|±o¨ì¦^¶ÇÈ:FF1B68F015357E86C877EA4D75ACB0A1C774ED26EF2670C4E40B65D2CDFE108E96E532F89FB911EAFB8EEFE7995BEC2E | 
			 
		  | 
	 
	
		| ¦^³»ºÝ | 
		 | 
	 
	
		  | 
	 
	
		iswith
 
 
  µù¥U®É¶¡: 2022-11-04 ¤å³¹: 93
 
  ²Ä 3 ¼Ó
  | 
		
			
				 µoªí©ó: ¬P´Á¥| ¤Q¤ë 26, 2023 7:22 pm    ¤å³¹¥DÃD:  | 
				     | 
			 
			
				
  | 
			 
			
				| ¦n¹³§Únetsuite.dll ¤¤¦³这个3 ¦¸des¨ç数,§A¥i¥H¥[§ÚWX¡GZ68256904¡A¥ý试¦Z给费¥Î | 
			 
		  | 
	 
	
		| ¦^³»ºÝ | 
		 | 
	 
	
		  | 
	 
	
		iswith
 
 
  µù¥U®É¶¡: 2022-11-04 ¤å³¹: 93
 
  ²Ä 4 ¼Ó
  | 
		
			
				 µoªí©ó: ¬P´Á¥| ¤Q¤ë 26, 2023 7:26 pm    ¤å³¹¥DÃD:  | 
				     | 
			 
			
				
  | 
			 
			
				*DESEncode(cstr,ckey,@cErrorMsg,nCipherMode,nPaddingMode)
 
		  *cstr			¥²传
 
		  *ckey			¥²传
 
		  *cErrorMsg    ¥²传	Éݱ`«H®§
 
		  *nCipherMode 	«D¥²传  Àq认È ECB 	 «ö»Ý nCipherMode©wúå 
 
		  *nPaddingMode «D¥²传  Àq认È Zeros «ö»Ý PaddingMode©wúå
 
	  *¥¢败ªð¦^ªÅ¦ê,µM¦Z¨ú¥XlcErrorMsg
 
 
 
 
*DESDecode(cstr,ckey,@cErrorMsg,nCipherMode,nPaddingMode)
 
		  *cstr			¥²传
 
		  *ckey			¥²传
 
		  *cErrorMsg    ¥²传	Éݱ`«H®§
 
		  *nCipherMode 	«D¥²传  Àq认È ECB   «ö»Ý nCipherMode©wúå 
 
		  *nPaddingMode «D¥²传  Àq认È Zeros «ö»Ý PaddingMode©wúå
 
	  *¥¢败ªð¦^ªÅ¦ê,µM¦Z¨ú¥XlcErrorMsg | 
			 
		  | 
	 
	
		| ¦^³»ºÝ | 
		 | 
	 
	
		  | 
	 
	
		jimmy987
 
 
  µù¥U®É¶¡: 2003-06-26 ¤å³¹: 33
 
  ²Ä 5 ¼Ó
  | 
		
			
				 µoªí©ó: ¬P´Á¤ ¤Q¤ë 27, 2023 6:30 pm    ¤å³¹¥DÃD: ·PÁÂiswith¤j¤jÀ°¦£, À°¦£§¹¦¨DLL»s§@ | 
				     | 
			 
			
				
  | 
			 
			
				| ·PÁÂiswith¤j¤jÀ°¦£, À°¦£§¹¦¨DLL»s§@¤Î×§ï, ³t«×§Ö¤S¦n,  ¶}µo¶O¥Î, §Ú·|§ÖÂI¶×µ¹§A. | 
			 
		  | 
	 
	
		| ¦^³»ºÝ | 
		 | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
  	 
	    
  	   | 
 	
±z µLªk ¦b³oÓª©±µoªí¤å³¹ ±z µLªk ¦b³oÓª©±¦^ÂФ峹 ±z µLªk ¦b³oÓª©±½s¿è¤å³¹ ±z µLªk ¦b³oÓª©±§R°£¤å³¹ ±z µLªk ¦b³oÓª©±¶i¦æ§ë²¼ ±z µLªk ¦b³oÓª©±ªþ¥[ÀÉ®× ±z µLªk ¦b³oÓª©±¤U¸üÀÉ®×
  | 
   
  
  
Powered by phpBB © 2001, 2005 phpBB Group ¥¿Å餤¤å»y¨t¥Ñ phpbb-tw ºûÅ@»s§@ 
		 |