問題タブ [tripledes]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - TripleDES in Perl/PHP/ColdFusion
Recently a problem arose regarding hooking up an API with a payment processor who were requesting a string to be encrypted to be used as a token, using the TripleDES standard. Our Applications run using ColdFusion, which has an Encrypt tag - that supports TripleDES - however the result we were getting back was not what the payment processor expected.
First of all, here is the resulting token the payment processor were expecting.
And below is the snippet of ColdFusion we were using, and the resulting string.
As you can see, this was not returning the string we were hoping for. Seeking a solution, we ditched ColdFusion for this process and attempted to reproduce the token in PHP.
Now I'm aware that various languages implement encryption in different ways - for example in the past managing encryption between a C# application and PHP back-end, I've had to play about with padding in order to get the two to talk, but my experience has been that PHP generally behaves when it comes to encryption standards.
Anyway, on to the PHP source we tried, and the resulting string.
As you can plainly see, we've got another string that differs from both the string expected by the payment processor AND the one produced by ColdFusion. Cue head-against-wall integration techniques.
After many to-and-fro communications with the payment processor (lots and lots of reps stating 'we can't help with coding issues, you must be doing it incorrectly, read the manual') we were finally escalated to someone with more than a couple of brain-cells to rub together, who was able to step back and actually look at and diagnose the issue.
He agreed, our CF and PHP attempts were not resulting in the correct string. After a quick search, he also agreed that it was not neccesarily our source, but rather how the two languages implemented their vision of the TripleDES standard.
Coming into the office this morning, we were met by an email with a snippet of source code, in Perl. This is was the code they were directly using on their end to produce the expected token.
So, there we have it. Three languages, three implementations of what they quote in the documentation as TripleDES Standard Encryption, and three totally different resulting strings.
My question is, from your experience of these three languages and their implementations of the TripleDES algorithm, have you been able to get any two of them to give the same response, and if so what tweaks to the code did you have to make in order to come to the result?
I understand this is a very drawn out question, but I wanted to give clear and precise setting for each stage of testing that we had to perform.
I'll also be performing some more investigatory work on this subject later, and will post any findings that I come up with to this question, so that others may avoid this headache.
php - PHP と RSA / Triple DES を使用して XML ドキュメントのフィールドを暗号化する方法
私は、統計処理のために州の IT 機関に XML 形式でデータを送信する必要がある南アフリカの学校向けのアプリケーションを開発しています。現在、PHP のDOMDocumentクラスを使用して XML ファイルを生成しています。
私のファイルは、第 1 段階の検証プロセスを経ています。次の段階では、XML ファイルの暗号化と圧縮を実装します。圧縮は単純な GZip であるため、心配する必要はありません。
仕様書では、RSA 暗号化 (ソフトウェアに実装するために RSA キーが発行されます) と、Triple DES などの何らかの形式の対称暗号化 (ただし、これは「例」であり、任意のアルゴリズムをhttp://www.w3.org/TR/xmldsig-core使用できます) の両方が使用されていることを示しています。実装されます)。私がこれを正しく理解していれば、RSA 暗号化は、フィールドの実際の暗号化に使用される対称鍵をエンコードすることです。
仕様書には、「XML ファイルの暗号化は、ファイル全体または特定の要素に対して実行できる」とも書かれています。この段階ではどちらが簡単なのかよくわからないので、どちらかの答えで十分です!
要件は、名前ではなく XML タグのコンテンツを暗号化することだと思います (図のようにhttp://www.w3.org/TR/xmlenc-core/#sec-eg-Element-Content-Character)。
これが漠然としているように思われる場合は、お詫び申し上げます。現在、私が持っている情報はすべてであり、エージェンシーの担当者は、(VisualBasic .NET) コード サンプルですべてを説明する必要があると喜んで言っています... このコード サンプルを調べたい場合は、以下を参照してください。次の ZIP ファイルの Word ドキュメントの約 213 ページ以降。http://www.sita.co.za/doe_lurits/DEVS-00118%20Rev%201.2%2012%20Jan%202009.zip
誰かが私を助けたり、正しい方向に向けることができれば、感謝します。
c# - TDES で暗号化および復号化するときの不正なデータ
TDES で大きな文字列を暗号化し、復号化しようとしています。何が悪いのか理解できません。復号化で READ 機能を実行すると、暗号化例外から「Bad Data」が発生します。(コメントで行をマークしました)
文字列を生成して暗号化するには:
文字列を復号化するには
テストするコード
c# - C#とPHPでのTripleDES暗号化は同じではありませんか(PKCS7、ECB)?
私はこれを理解するために数時間を費やしましたが、それを機能させることができません。PHPで照合する必要のあるC#暗号化ルーチンがあります。C#のバージョンを変更することはできません。これはオプションではありません(サードパーティはこれに固執しています)。
C#コードは次のとおりです。
これが私がPHPで思いついたものの中で最高のものです:
私の知る限り、PHP側でPKCS7のパディングを適切に処理しています。他に何を試すべきかわかりません。
注意すべき点の1つは、C#はWindowsで、PHPはLinuxで発生していることですが、それが違いを生むかどうかはわかりません。
c# - c#tripleDESCryptoがSQLから保存および取得されて機能しない
そうですね、msSQLデータベースでは、ストアドプロシージャを使用して保存および取得しています。配置する前にc#Windowsフォームで一部のデータを暗号化しようとしていますが、もちろん、データをプルバックするときに復号化しています。すべての暗号化はC#側で処理されています。マイクロソフトのtripleDESCryptoServiceクラス(メモリバージョン、2番目の例)の暗号化と復号化のサンプルコードをそのまま使用しています。値は暗号化されてデータベースに送信されますが、値を取得すると「不正なデータ」エラーが発生します。暗号化呼び出しのサンプルは...
次に、txt_Last_Nameがデータベースに送信され、データベースに何かがあることがわかります。データベースでは、名前はvarchar(20)タイプです。
復号化呼び出しのサンプルは...
「csDecrypt.Read(fromEncrypt、0、fromEncrypt.Length);」で復号化関数を爆撃します。理由がわかりません。データベースに正しく保存されていないのか、変換が正しくないのかわかりません。
それが何かを意味する場合、復号化関数に入る「データ」はサイズ16であり、ゼロ以外の値を含みますが、「byte[]fromEncrypt」はすべてゼロを含むサイズ16の配列です。
助けてくれてありがとう!
c# - TripleDES キーのランダム バイトを生成する C#
TripleDES 暗号化用のバイト配列を生成する必要があります。.generateKey()別のアプリケーションに渡すためにキーのバイトを知る必要があるため、使用したくありません。
返信ありがとうございますが、1 つのことを忘れていました。バイトは奇数パリティでなければなりません。そうしないと、それらから TripleDES キーを生成できません。私は奇数パリティにあまり詳しくないので、奇数パリティがあるかどうかのバイトチェックを作成する必要があると思います。それを配列に入れる場合は、そうでない場合は入れません。
aes - データのDES、トリプルDES、AES、blowfish暗号化の比較
これらの暗号化アルゴリズムを比較するための長所と短所を一緒に持っている人はいますか?
c# - C#復号化をPythonPyDesに変換します
コードをC#からPythonに変換するのに問題があります。MartijnのC#ブログは、暗号化/復号化のための優れたプログラムです[以下に同封]が、PythonバージョンのpyDesに直接変換することはできません[以下のサンプル]
PyDES:
元のpyDesを変更して、CBCの代わりにECBを使用しました。どの弦も一致せず、私はロープの端にいます。助けてください!ありがとう
web-applications - ランダムに生成されたキーによる暗号化と復号化?
私は j2me プログラマーです。私のプロジェクトは、HTTP メソッドを介してサーバーにデータを送信することに関連しています。Bouncy Castle (Triple DES) を使用して j2me 側でデータを暗号化します。サーバー側のコーディングも担当しています。
次に、サーバー側で受信したデータを復号化してデータベースに保存します。
ここでは、コーディング自体でキーを静的に想定しています。サーバー側と j2me 側では、同じキー値を使用します。
しかし、ここに要件に基づく 1 つの問題があります。キーはランダムに生成され、ユーザーには知られていません。
この場合、j2me の部分で何らかのキーを使用してデータを暗号化すると、サーバーはキーを知らずにどのように復号化するのでしょうか?
または、他のメカニズムがありますので、問題の解決にご協力ください。
ありがとう、よろしく、 Sivakumar.J
c# - C#.NETのフルトリプルDESMACであなたの助けが必要です
私の仕事には、.NETの完全なトリプルDES MAC機能が必要です([ISO 9797-1]で、出力変換1、切り捨てなし、およびブロック暗号の代わりにトリプルDESを使用するMACアルゴリズム1として定義されています)
私の問題は、C#.NETでこのアルゴリズムを実装する方法がわからないことです
それを実装するのに役立つ提案(またはコードスニペット)はありますか(.NETクラスとメソッド)
前もって感謝します!よろしく、Hai-Binh LE