Giter Club home page Giter Club logo

Comments (12)

shyandsy avatar shyandsy commented on August 30, 2024

ok. I will publish a new version which support aes ccm and gcm net week.

我会在下周发一个新版本支持AES ccm和gcm。

from cipher2.

shyandsy avatar shyandsy commented on August 30, 2024

@puckyeh
hi, i published a new version to support GCM for android.

Could u help to test it on android?

if no problem I will implement the ios part

新版本支持android平台gcm加解密。可以帮测试下。
没有什么问题的话,我就开始实现ios系统支持了。

from cipher2.

puckyeh avatar puckyeh commented on August 30, 2024

android gcm 加解密 測試看起來沒問題!!

from cipher2.

shyandsy avatar shyandsy commented on August 30, 2024

from cipher2.

puckyeh avatar puckyeh commented on August 30, 2024

我自行用 php 試著做 aes-128-gcm 的加解密
和你轉出來的結果好像不同耶!!

$plaintext = ('{"token":"ABCDEFGHIJKLMNOPQRSTUVWXYZ","device":"AABBCCDD"}');
$key = '8c775176c699f9cd';
$iv = '0000000756632532';
$cipher = "aes-128-gcm";

php 轉出來的結果是
yAChpzwcQ89E7IqvzBNU7Ty5evziE29hLn1VtYqTWUqewxD7jCY0Au2OeovyUlsB7wFTOVk97Q3rZKKMEvl3Je1j

用你的 lib 轉出來的結果是
YnT2s2JmGMXGgT12BT9pn5S6+nf/2A6KejUdyy7Yhq30HrLL2c/B6acdjgazJCQ1ngjuFHr6Zu5eXGGnb3WGN1s2lCs9WFjQje0=

from cipher2.

shyandsy avatar shyandsy commented on August 30, 2024

@puckyeh

明白你的问题了,我需要修改一下秘钥参数格式。兼容更多的表示方式

from cipher2.

shyandsy avatar shyandsy commented on August 30, 2024

@puckyeh
可以贴一下你的php加密代码么

from cipher2.

puckyeh avatar puckyeh commented on August 30, 2024

加密
$ciphertext = openssl_encrypt($plaintext, $cipher, $key, $options=0, $iv, $tag);
解密
$original_plaintext = openssl_decrypt($ciphertext, $cipher, $key, $options=0, $iv, $tag);

from cipher2.

shyandsy avatar shyandsy commented on August 30, 2024

@puckyeh

麻烦贴完整可运行代码,不要让我猜参数,整理你的代码。

from cipher2.

puckyeh avatar puckyeh commented on August 30, 2024

不好意思, 當時想貼完整的, 但都是亂碼, 就沒想那麼多了, 我重新貼!!
$tag 預設就是 null

$plaintext = ('{"token":"ABCDEFGHIJKLMNOPQRSTUVWXYZ","device":"AABBCCDD"}');
$key = '8c775176c699f9cd';
$iv = '0000000756632532';
$cipher = "aes-128-gcm";
$tag = null;
if (in_array($cipher, openssl_get_cipher_methods()))
{
$ciphertext = openssl_encrypt($plaintext, $cipher, $key, $options=0, $iv, $tag);
echo $ciphertext;
$original_plaintext = openssl_decrypt($ciphertext, $cipher, $key, $options=0, $iv, $tag);
echo $original_plaintext;
}

from cipher2.

puckyeh avatar puckyeh commented on August 30, 2024

我剛剛才發現, 你的 nonce 有做過 base64 的編碼
所以我在 php 上的 $iv 也補做了 base64, 編碼出來的結果看起來對一半, 貼給你看看, 希望對你有幫助!!

以下為參數 :
$plaintext = '{"badgeCount":"3"}';
$key = '8c775176c699f9cd';
$iv = '0000000756632532';

php 的編碼結果
"pVlKqNVeHv06aENl2nau/n4M"

cipher2 的編碼結果
"pVlKqNVeHv06aENl2nau/n4M8G2uIl7vt0BFM7uFTtQb0Q==\n"

from cipher2.

shyandsy avatar shyandsy commented on August 30, 2024

from cipher2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.