C# 和 php 中的 Ruby string#crypt

发布于 2024-08-14 13:04:36 字数 352 浏览 4 评论 0原文

我有一个 ruby​​ 客户端程序,它使用 string#crypt 来加密密码,

  encrypted = password.crypt(SALT)
  # removing first two characters which actually are the salt for safety
  return encrypted[2, encrypted.size - 2]

然后将其发送到服务器以与存储的预加密字符串进行比较。 我如何需要能够从 ac# 应用程序和 php 网页发送相同的加密密码,并且仍然能够从任何其他客户端使用相同的密码登录。

C# 和 php 中用于加密的等效代码是什么?

I have a ruby client program that encrypts a password with string#crypt like so

  encrypted = password.crypt(SALT)
  # removing first two characters which actually are the salt for safety
  return encrypted[2, encrypted.size - 2]

it then sends it to a server for comparison with it's stored pre-encrypted string.
how ever I need to be able to send the same encrypted password form a c# app and a php web page and still be able to log in with the same password from any of the other clients.

what would be the equivalent code in C# and php for the encryption?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凶凌 2024-08-21 13:04:36

C

  • crypt(3)

    <块引用>

    crypt()是密码加密函数。它基于数据加密标准算法,其变化旨在(除其他外)阻止使用密钥搜索的硬件实现。

    key 是用户输入的密码。

    salt 是从 [a-zA-Z0-9./] 集合中选择的两个字符的字符串。该字符串用于以 4096 种不同方式之一扰乱算法。

Ruby

  • 加密

    <块引用>

    通过调用标准库函数 crypt 将单向加密哈希应用于 str。参数是盐字符串,长度应为两个字符,每个字符取自 [a-zA-Z0-9./]。

PHP

  • 加密

    <块引用>

    crypt() 将使用基于标准 Unix DES 的加密算法或系统上可用的替代算法返回加密字符串。

Python

  • crypt.crypt

    <块引用>

    该模块实现了 crypt(3) 例程的接口,该例程是基于修改的 DES 算法的单向哈希函数;

C#

.NET Framework 不包含用于 Unix crypt 函数的 API,但以下是一些提供实现的库:

  • CryptAPI

    <块引用>

    CryptAPI 是一个 C# 库,包含 .NET 框架(NT、NTLM、BlowFish、DES 和 MD5)中未实现的算法,链接和模拟用 C# 重新编程的 crypt() unix 函数。主要目的是提供向后兼容性。

  • Unix crypt() 的 AC# 实现

C

  • crypt(3)

    crypt() is the password encryption function. It is based on the Data Encryption Standard algorithm with variations intended (among other things) to discourage use of hardware implementations of a key search.

    key is a user's typed password.

    salt is a two-character string chosen from the set [a-zA-Z0-9./]. This string is used to perturb the algorithm in one of 4096 different ways.

Ruby

  • crypt

    Applies a one-way cryptographic hash to str by invoking the standard library function crypt. The argument is the salt string, which should be two characters long, each character drawn from [a-zA-Z0-9./].

PHP

  • crypt

    crypt() will return an encrypted string using the standard Unix DES-based encryption algorithm or alternative algorithms that may be available on the system.

Python

  • crypt.crypt

    This module implements an interface to the crypt(3) routine, which is a one-way hash function based upon a modified DES algorithm;

C#

The .NET Framework doesn't include an API for the Unix crypt function, but here are some libraryies that provide implementations:

  • CryptAPI

    CryptAPI is a C# library that contains unimplemented algorithms in the .NET framework (NT, NTLM, BlowFish, DES and MD5) linking and emulating the crypt() unix function re-programmed in C#. The main purpose is to provide backward compatiblity.

  • A C# implementation of Unix crypt()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文