简体   繁体   English

Ruby#string在c#和php中加密

[英]Ruby string#crypt in c# and php

I have a ruby client program that encrypts a password with string#crypt like so 我有一个ruby客户端程序,用字符串#crypt加密密码,如此

  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 ac# app and a php web page and still be able to log in with the same password from any of the other clients. 我怎么能够从ac#app和php网页发送相同的加密密码,并且仍然能够使用来自任何其他客户端的相同密码登录。

what would be the equivalent code in C# and php for the encryption? 加密的C#和php中的等效代码是什么?

C C

  • crypt(3) 隐窝(3)

    crypt() is the password encryption function. crypt()是密码加密函数。 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. key是用户输入的密码。

    salt is a two-character string chosen from the set [a-zA-Z0-9./]. salt是从集合[a-zA-Z0-9./]中选择的双字符串。 This string is used to perturb the algorithm in one of 4096 different ways. 该字符串用于以4096种不同方式之一扰乱算法。

Ruby 红宝石

  • crypt 隐窝

    Applies a one-way cryptographic hash to str by invoking the standard library function crypt. 通过调用标准库函数crypt将单向加密哈希应用于str。 The argument is the salt string, which should be two characters long, each character drawn from [a-zA-Z0-9./]. 参数是salt字符串,它应该是两个字符长,每个字符都是从[a-zA-Z0-9./]中提取的。

PHP 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. crypt()将使用标准的基于Unix DES的加密算法或系统上可用的替代算法返回加密字符串。

Python 蟒蛇

  • crypt.crypt 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; 该模块实现了crypt(3)例程的接口,该例程是基于修改的DES算法的单向散列函数;

C# C#

The .NET Framework doesn't include an API for the Unix crypt function, but here are some libraryies that provide implementations: .NET Framework不包含Unix crypt函数的API,但是这里有一些提供实现的库:

  • CryptAPI 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#. CryptAPI是一个C#库,它包含.NET框架中的未实现算法(NT,NTLM,BlowFish,DES和MD5),用于链接和模拟在C#中重新编程的crypt()unix函数。 The main purpose is to provide backward compatiblity. 主要目的是提供向后兼容性。

  • AC# implementation of Unix crypt() Unix crypt的AC#实现()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM