pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<i id='YaW64'><tr id='YaW64'><dt id='YaW64'><q id='YaW64'><span id='YaW64'><b id='YaW64'><form id='YaW64'><ins id='YaW64'></ins><ul id='YaW64'></ul><sub id='YaW64'></sub></form><legend id='YaW64'></legend><bdo id='YaW64'><pre id='YaW64'><center id='YaW64'></center></pre></bdo></b><th id='YaW64'></th></span></q></dt></tr></i><div class="bdvj1hn" id='YaW64'><tfoot id='YaW64'></tfoot><dl id='YaW64'><fieldset id='YaW64'></fieldset></dl></div>
<tfoot id='YaW64'></tfoot>
    <legend id='YaW64'><style id='YaW64'><dir id='YaW64'><q id='YaW64'></q></dir></style></legend>

    <small id='YaW64'></small><noframes id='YaW64'>

        • <bdo id='YaW64'></bdo><ul id='YaW64'></ul>

      1. 在 C# 中解密用 3DES 加密的 ColdFusion 中的字符串

        Decrypting a string in ColdFusion encrypted with 3DES in C#(在 C# 中解密用 3DES 加密的 ColdFusion 中的字符串)

            • <bdo id='bjoQ2'></bdo><ul id='bjoQ2'></ul>
                • <legend id='bjoQ2'><style id='bjoQ2'><dir id='bjoQ2'><q id='bjoQ2'></q></dir></style></legend>
                  <i id='bjoQ2'><tr id='bjoQ2'><dt id='bjoQ2'><q id='bjoQ2'><span id='bjoQ2'><b id='bjoQ2'><form id='bjoQ2'><ins id='bjoQ2'></ins><ul id='bjoQ2'></ul><sub id='bjoQ2'></sub></form><legend id='bjoQ2'></legend><bdo id='bjoQ2'><pre id='bjoQ2'><center id='bjoQ2'></center></pre></bdo></b><th id='bjoQ2'></th></span></q></dt></tr></i><div class="5vdbvvt" id='bjoQ2'><tfoot id='bjoQ2'></tfoot><dl id='bjoQ2'><fieldset id='bjoQ2'></fieldset></dl></div>

                  <tfoot id='bjoQ2'></tfoot>

                    <tbody id='bjoQ2'></tbody>

                  <small id='bjoQ2'></small><noframes id='bjoQ2'>

                  本文介紹了在 C# 中解密用 3DES 加密的 ColdFusion 中的字符串的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我們很難在 ColdFusion 中解密之前使用 3DES 和 C# 加密的字符串.這是我們最初用來加密字符串的代碼:

                  We are having difficulty decrypting a string in ColdFusion that was previously encrypted with 3DES and C#. Here is the code we used to encrypt the string initially:

                      public static string EncryptTripleDES(string plaintext, string key)
                      {
                      TripleDESCryptoServiceProvider DES = new TripleDESCryptoServiceProvider();
                      MD5CryptoServiceProvider hashMD5 = new MD5CryptoServiceProvider();
                      DES.Key = hashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(key));
                      DES.Mode = CipherMode.ECB;
                      ICryptoTransform DESEncrypt = DES.CreateEncryptor();
                      byte[] Buffer = ASCIIEncoding.ASCII.GetBytes(plaintext);
                  
                      string EncString = Convert.ToBase64String(DESEncrypt.TransformFinalBlock(Buffer, 0, Buffer.Length));
                      EncString = EncString.Replace("+", "@@12");
                  
                      return EncString;
                      }
                  

                  我們已嘗試使用此處的建議:

                  We have tried using the suggestions here:

                  TripleDES 加密 - .NET 和 ColdFusion 效果不佳

                  ..沒有運氣.這是我們的 CF 代碼和錯誤:

                  ..with no luck. Here is our CF code and the error:

                    <cfset variables.theKey = "blahblah" />
                    <cfset variables.theAlgorithm = "DESede/CBC/PKCS5Padding">
                    <cfset variables.theEncoding = "Base64">
                    <cfset strTest = decrypt(#DB.PASSWORD#, variables.theKey, variables.theAlgorithm, variables.theEncoding)>
                  

                  錯誤返回:嘗試加密或解密輸入字符串時出錯:''無法解碼字符串blahblah"

                  Error returned: An error occurred while trying to encrypt or decrypt your input string: '' Can not decode string "blahblah"

                  所以,看起來它是在嘗試解密密鑰而不是字符串,但這不是 ColdFusion 中解密函數(shù)的概述方式.有什么想法嗎?

                  So, it looks like it's trying to decrypt the key and not the string, but that's not how the decrypt function is outlined in ColdFusion. Any ideas?

                  更新:嘗試使用以下 CF 代碼,但返回的錯誤仍然是嘗試加密或解密您的輸入字符串時發(fā)生錯誤:未正確填充最終塊."

                  UPDATE: Attempted to use the following CF code, but the error returned is still "An error occurred while trying to encrypt or decrypt your input string: Given final block not properly padded."

                  <cfset dbPassword  = "Hx41SYUrmnFPa31QCH1ArCHN1YOF8IAL">
                  <cfset finalText   = replace(dbPassword, "@@12", "+", "all")>
                  <cfset theKey      = "abcdefgh">
                  <cfset theKeyInBase64 = toBase64(theKey)>
                  <cfset hashedKey   = hash( theKeyInBase64, "md5" )>
                  <cfset padBytes    = left( hashedKey, 16 )>
                  <cfset keyBytes    = binaryDecode( hashedKey & padBytes , "hex" )>
                  <cfset finalKey    = binaryEncode( keyBytes, "base64" )>
                  <cfset decrypted = decrypt( finalText, finalKey, "DESede/ECB/PKCS5Padding", "base64" )>
                  Decrypted String: <cfdump var="#decrypted#">
                  

                  更新:

                  如果您關(guān)注評論,解決方案是更改:

                  The solution if you follow the comments was to change:

                  <cfset hashedKey   = hash( theKeyInBase64, "md5" )>
                  

                  收件人:

                  <cfset hashedKey   = hash( theKey, "md5" )>
                  

                  最后的代碼是這樣的:

                  <cfset dbPassword  = "Hx41SYUrmnFPa31QCH1ArCHN1YOF8IAL">
                  <cfset finalText   = replace(dbPassword, "@@12", "+", "all")>
                  <cfset theKey      = "abcdefgh">
                  <cfset hashedKey   = hash( theKey, "md5" )>
                  <cfset padBytes    = left( hashedKey, 16 )>
                  <cfset keyBytes    = binaryDecode( hashedKey & padBytes , "hex" )>
                  <cfset finalKey    = binaryEncode( keyBytes, "base64" )>
                  <cfset decrypted = decrypt( finalText, finalKey, "DESede/ECB/PKCS5Padding", "base64" )>
                  Decrypted String: <cfdump var="#decrypted#">
                  

                  推薦答案

                  看起來你的 c# 函數(shù)中需要處理一些額外的曲折以實現(xiàn)兼容性:

                  Looks like there a few extra twists in your c# function you need to handle to achieve compatibility:

                  1. .NET 函數(shù)修改加密字符串.你需要反轉(zhuǎn)這些更改,以便解密將其識別為有效的 base64:

                  1. The .NET function modifies the encrypted string. You need to reverse those changes so decrypt will recognize it as valid base64:

                  <!--- reverse replacements in encrypted text ie #DB.Password# --->
                  <cfset dbPassword = "uAugP@@12aP4GGBOLCLRqxlNPL1PSHfTNEZ">
                  <cfset finalText = replace(dbPassword, "@@12", "+", "all")>
                  

                • 該函數(shù)還使用創(chuàng)建 16 字節(jié)密鑰的哈希.CF/java 需要 24 字節(jié)密鑰.因此,您必須首先對密鑰進行哈希處理,然后 將其填充到適當(dāng)?shù)拈L度.否則,decrypt() 會抱怨密鑰太小.

                • The function also uses a hash which creates a 16 byte key. CF/java require a 24 byte key for that algorithm. So you must first hash the key and pad it to the proper length. Otherwise, decrypt() will complain the key is too small.

                  注意:CF 還期望最終密鑰是 base64 編碼的.錯誤 Can not decode string "blahblah" 表明您的輸入鍵不在 base64 中.

                  Note: CF also expects the final key to be base64 encoded. The error Can not decode string "blahblah" suggests your input key is not in base64.

                  <!--- hash and pad the key (ie "blahblah"), then convert to base64 for CF --->
                  <cfset theKeyInBase64 = "rpaSPvIvVLlrcmtzPU9/c67Gkj7yL1S5">
                  <cfset hashedKey   = hash( theKeyInBase64, "md5" )>
                  <cfset padBytes    = left( hashedKey, 16 )>
                  <cfset keyBytes    = binaryDecode( hashedKey & padBytes , "hex" )>
                  <cfset finalKey    = binaryEncode( keyBytes, "base64" )>
                  

                • 最后,反饋模式必須匹配.由于 .NET 代碼使用安全性較低的 ECB 模式,CF 代碼也必須使用該模式.

                • Finally, the feedback modes must match. Since the .NET code uses the less secure ECB mode, the CF code must use that mode as well.

                  <!--- .net code uses the less secure ECB mode --->
                  <cfset decrypted = decrypt( finalText, finalKey, "DESede/ECB/PKCS5Padding", "base64" )>
                  Decrypted String: <cfdump var="#decrypted#">
                  

                • 另一個需要注意的問題是編碼.在 CF 中,加密/解密始終將輸入字符串解釋為 UTF8,而 .NET 函數(shù)使用 ASCII.為了完全兼容,雙方應(yīng)使用相同的編碼,在本例中為 UTF8.

                • One other issue to watch out for is encoding. In CF, encrypt/decrypt always interpret the input string as UTF8, whereas the .NET function uses ASCII. For full compatibility, both sides should use the same encoding, in this case UTF8.

                  <小時>

                  更新:

                  我使用任意 8 個字符的密鑰(而不是 base64 字符串)對上述內(nèi)容進行了測試,CF9 仍然正確解密了該字符串.

                  I tested the above with an arbitrary 8 character key (instead of a base64 string) and CF9 still decrypted the string properly.

                  // .NET Code
                  String text = "some text to encrypt";
                  String key = "abcdefgh";
                  String encrypted = EncryptTripleDES(text, key);
                  // result: encrypted=Hx41SYUrmnFPa31QCH1ArCHN1YOF8IAL
                  Console.WriteLine("encrypted={0}", encrypted);
                  
                  <!--- same code, only the encrypted text and key changed ---> 
                  <cfset dbPassword  = "Hx41SYUrmnFPa31QCH1ArCHN1YOF8IAL">
                  <cfset finalText   = replace(dbPassword, "@@12", "+", "all")>
                  <cfset theKey      = "abcdefgh">
                  <cfset hashedKey   = hash( theKey, "md5" )>
                  .... 
                  

                  這篇關(guān)于在 C# 中解密用 3DES 加密的 ColdFusion 中的字符串的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!
                • 相關(guān)文檔推薦

                  What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                  Calling A Button OnClick from a function(從函數(shù)調(diào)用按鈕 OnClick)
                    1. <legend id='KamIP'><style id='KamIP'><dir id='KamIP'><q id='KamIP'></q></dir></style></legend>

                      <small id='KamIP'></small><noframes id='KamIP'>

                        <bdo id='KamIP'></bdo><ul id='KamIP'></ul>

                      • <i id='KamIP'><tr id='KamIP'><dt id='KamIP'><q id='KamIP'><span id='KamIP'><b id='KamIP'><form id='KamIP'><ins id='KamIP'></ins><ul id='KamIP'></ul><sub id='KamIP'></sub></form><legend id='KamIP'></legend><bdo id='KamIP'><pre id='KamIP'><center id='KamIP'></center></pre></bdo></b><th id='KamIP'></th></span></q></dt></tr></i><div class="5ddt777" id='KamIP'><tfoot id='KamIP'></tfoot><dl id='KamIP'><fieldset id='KamIP'></fieldset></dl></div>

                          <tfoot id='KamIP'></tfoot>
                              <tbody id='KamIP'></tbody>
                            主站蜘蛛池模板: 尚为传动-专业高精密蜗轮蜗杆,双导程蜗轮蜗杆,蜗轮蜗杆减速机,蜗杆减速机生产厂家 | 深圳APP开发_手机软件APP定制外包_小程序开发公司-来科信 | 玉米深加工机械,玉米加工设备,玉米加工机械等玉米深加工设备制造商-河南成立粮油机械有限公司 | 酒店品牌设计-酒店vi设计-酒店标识设计【国际级】VI策划公司 | 深圳善跑体育产业集团有限公司_塑胶跑道_人造草坪_运动木地板 | 安徽控制器-合肥船用空调控制器-合肥家电控制器-合肥迅驰电子厂 安徽净化板_合肥岩棉板厂家_玻镁板厂家_安徽科艺美洁净科技有限公司 | 玻璃钢格栅盖板|玻璃钢盖板|玻璃钢格栅板|树篦子-长沙川皖玻璃钢制品有限公司 | 除尘布袋_液体过滤袋_针刺毡滤料-杭州辉龙过滤技术有限公司 | 金蝶帐无忧|云代账软件|智能财税软件|会计代账公司专用软件 | uv固化机-丝印uv机-工业烤箱-五金蚀刻机-分拣输送机 - 保定市丰辉机械设备制造有限公司 | 杭州货架订做_组合货架公司_货位式货架_贯通式_重型仓储_工厂货架_货架销售厂家_杭州永诚货架有限公司 | 充气膜专家-气膜馆-PTFE膜结构-ETFE膜结构-商业街膜结构-奥克金鼎 | 不锈钢螺丝 - 六角螺丝厂家 - 不锈钢紧固件 - 万千紧固件--紧固件一站式采购 | 气体检测仪-氢气检测仪-可燃气体传感器-恶臭电子鼻-深国安电子 | 信阳网站建设专家-信阳时代网联-【信阳网站建设百度推广优质服务提供商】信阳网站建设|信阳网络公司|信阳网络营销推广 | 北京普辉律师事务所官网_北京律师24小时免费咨询|法律咨询 | 专业生产动态配料系统_饲料配料系统_化肥配料系统等配料系统-郑州鑫晟重工机械有限公司 | 杭州ROHS检测仪-XRF测试仪价格-百科 | 河南生物显微镜,全自动冰冻切片机-河南荣程联合科技有限公司 | 美的商用净水器_美的直饮机_一级代理经销商_Midea租赁价格-厂家反渗透滤芯-直饮水批发品牌售后 | 老城街小面官网_正宗重庆小面加盟技术培训_特色面馆加盟|牛肉拉面|招商加盟代理费用多少钱 | 沈阳网站建设_沈阳网站制作_沈阳网页设计-做网站就找示剑新零售 沈阳缠绕膜价格_沈阳拉伸膜厂家_沈阳缠绕膜厂家直销 | 冷柜风机-冰柜电机-罩极电机-外转子风机-EC直流电机厂家-杭州金久电器有限公司 | 冷藏车厂家|冷藏车价格|小型冷藏车|散装饲料车厂家|程力专用汽车股份有限公司销售十二分公司 | 全自动实验室洗瓶机,移液管|培养皿|进样瓶清洗机,清洗剂-广州摩特伟希尔机械设备有限责任公司 | 空冷器|空气冷却器|空水冷却器-无锡赛迪森机械有限公司[官网] | 布袋除尘器-单机除尘器-脉冲除尘器-泊头市兴天环保设备有限公司 布袋除尘器|除尘器设备|除尘布袋|除尘设备_诺和环保设备 | 自动检重秤-动态称重机-重量分选秤-苏州金钻称重设备系统开发有限公司 | 锌合金压铸-铝合金压铸厂-压铸模具-冷挤压-誉格精密压铸 | 扒渣机,铁水扒渣机,钢水扒渣机,铁水捞渣机,钢水捞渣机-烟台盛利达工程技术有限公司 | 东莞动力锂电池保护板_BMS智能软件保护板_锂电池主动均衡保护板-东莞市倡芯电子科技有限公司 | LHH药品稳定性试验箱-BPS系列恒温恒湿箱-意大利超低温冰箱-上海一恒科学仪器有限公司 | 膏剂灌装旋盖机-眼药水灌装生产线-西林瓶粉剂分装机-南通博琅机械科技 | CPSE安博会| 老城街小面官网_正宗重庆小面加盟技术培训_特色面馆加盟|牛肉拉面|招商加盟代理费用多少钱 | 超声骨密度仪,双能X射线骨密度仪【起草单位】,骨密度检测仪厂家 - 品源医疗(江苏)有限公司 | 智能风向风速仪,风速告警仪,数字温湿仪,综合气象仪(气象五要素)-上海风云气象仪器有限公司 | 大型低温冷却液循环泵-低温水槽冷阱「厂家品牌」京华仪器_京华仪器 | 北京翻译公司_同传翻译_字幕翻译_合同翻译_英语陪同翻译_影视翻译_翻译盖章-译铭信息 | 智能型高压核相仪-自动开口闪点测试仪-QJ41A电雷管测试仪|上海妙定 | 包塑丝_高铁绑丝_地暖绑丝_涂塑丝_塑料皮铁丝_河北创筹金属丝网制品有限公司 |