You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
761 B
25 lines
761 B
using System;
|
|
|
|
namespace Common.Helper.StringText
|
|
{
|
|
/// <summary>
|
|
/// 相关码的生成
|
|
/// </summary>
|
|
public class CodeHelper
|
|
{
|
|
/// <summary>
|
|
///获取文本数字码
|
|
/// </summary>
|
|
/// <param name="code">需要转换的文本</param>
|
|
/// <param name="length">需要码长度</param>
|
|
/// <returns></returns>
|
|
public string GetCode(string code, int length)
|
|
{
|
|
code = PinYinHelper.GetFirstPinyin(code);
|
|
var random = new Random();
|
|
var numberLength = length - code.Length;
|
|
code += random.Next(Convert.ToInt32(Math.Pow(10, numberLength)),Convert.ToInt32(Math.Pow(10, numberLength + 1)));
|
|
return code;
|
|
}
|
|
}
|
|
}
|
|
|