zoukankan      html  css  js  c++  java
  • RSADemo2

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace ERN.Tools.Common
    {
    /// <summary>
    /// 封装的一些通用方法
    /// </summary>
    public class RSA_Unit
    {
    static public string Base64EncodeBytes(byte[] byts)
    {
    return Convert.ToBase64String(byts);
    }
    static public byte[] Base64DecodeBytes(string str)
    {
    try
    {
    return Convert.FromBase64String(str);
    }
    catch
    {
    return null;
    }
    }
    /// <summary>
    /// 把字符串按每行多少个字断行
    /// </summary>
    static public string TextBreak(string text, int line)
    {
    var idx = 0;
    var len = text.Length;
    var str = new StringBuilder();
    while (idx < len)
    {
    if (idx > 0)
    {
    str.Append(' ');
    }
    if (idx + line >= len)
    {
    str.Append(text.Substring(idx));
    }
    else
    {
    str.Append(text.Substring(idx, line));
    }
    idx += line;
    }
    return str.ToString();
    }
    }

    static public class Extensions
    {
    /// <summary>
    /// 从数组start开始到指定长度复制一份
    /// </summary>
    static public T[] sub<T>(this T[] arr, int start, int count)
    {
    T[] val = new T[count];
    for (var i = 0; i < count; i++)
    {
    val[i] = arr[start + i];
    }
    return val;
    }
    static public void writeAll(this Stream stream, byte[] byts)
    {
    stream.Write(byts, 0, byts.Length);
    }
    }
    }

  • 相关阅读:
    (八)shell 计算命令
    (七)shell内建命令
    (六)shell数组深入解析
    (五)shell字符串深入解析
    输出链表的倒数第K个值
    反转链表
    调整该数组中数字的顺序,奇数在前,偶数在后
    基类与派生类的对象调用
    printf以%d形式输出浮点数的问题
    数值的整数次方
  • 原文地址:https://www.cnblogs.com/lockzy/p/11759032.html
Copyright © 2011-2022 走看看