public SignatureData(RequestMessagePublicKey message, byte[] sessionId) { _message = message; _sessionId = sessionId; _serviceName = ServiceName.Connection.ToArray(); _authenticationMethod = Ascii.GetBytes("publickey"); }
/// <summary> /// Initializes a new instance of the <see cref="RequestMessage"/> class. /// </summary> /// <param name="serviceName">Name of the service.</param> /// <param name="username">Authentication username.</param> /// <param name="methodName">The name of the authentication method.</param> protected RequestMessage(ServiceName serviceName, string username, string methodName) { _serviceName = serviceName.ToArray(); _userName = Utf8.GetBytes(username); _methodNameBytes = Ascii.GetBytes(methodName); _methodName = methodName; }
public static Bitmap ToAscii(Stream stream) { using (var factory = new ImageFactory()) { stream.Position = 0; factory.Load(stream); var processor = new Ascii { DynamicParameter = new AsciiParameters { CharacterCount = 5, FontSize = 3 } }; var handDrawingProcessor = new Drawing { DynamicParameter = new DrawingParameters { FilterType = DrawingParameters.EdgeFilterType.Sharpen } }; var processImage = processor.ProcessImage(factory); return(new Bitmap(processImage)); } }
public void AsciiToUtf16StringBasics(string original) { var encoded = (Span <byte>)Text.Encoding.ASCII.GetBytes(original); var decoded = Ascii.ToUtf16String(encoded); Assert.Equal(original, decoded); }
public void print(int x, int y, string text) { int x1 = x; int y1 = y; for (int i = 0; i < text.Length; i++) { switch (text[i]) { case '\n': y1 += 6; x1 = x; break; case ' ': x1 += 4; break; default: short glyph = Ascii.getGlyph(text[i]); int j = 14; do { if ((glyph & 1) != 0) { pixel(x1 + j % 3, y1 - 4 + j / 3); } glyph >>= 1; j--; } while (glyph > 0); x1 += 4; break; } } }
public void OnHeader(ReadOnlySpan <byte> name, ReadOnlySpan <byte> value) { var nameString = Ascii.ToUtf16String(name); var valueString = Ascii.ToUtf16String(value); Headers.Add(nameString, valueString); }
public override ScalarValue Decode(Stream inStream) { ScalarValue subtractionLength = Integer.Decode(inStream); ScalarValue difference = Ascii.Decode(inStream); return(new TwinValue(subtractionLength, difference)); }
/// <summary> /// Called when type specific data need to be loaded. /// </summary> protected override void LoadData() { ChannelType = ReadBinary(); LocalChannelNumber = ReadUInt32(); InitialWindowSize = ReadUInt32(); MaximumPacketSize = ReadUInt32(); _infoBytes = ReadBytes(); var channelName = Ascii.GetString(ChannelType, 0, ChannelType.Length); switch (channelName) { case SessionChannelOpenInfo.Name: Info = new SessionChannelOpenInfo(_infoBytes); break; case X11ChannelOpenInfo.Name: Info = new X11ChannelOpenInfo(_infoBytes); break; case DirectTcpipChannelInfo.NAME: Info = new DirectTcpipChannelInfo(_infoBytes); break; case ForwardedTcpipChannelInfo.NAME: Info = new ForwardedTcpipChannelInfo(_infoBytes); break; default: throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Channel type '{0}' is not supported.", channelName)); } }
public void Different_pixel_per_character_yield_different_images() { foreach (string file in this.images) { // arrange using (ImageFactory factory = new ImageFactory()) { factory.Load(file); Ascii processor = new Ascii(); processor.DynamicParameter = new AsciiParameters() { PixelPerCharacter = 2 }; Ascii processor2 = new Ascii(); processor2.DynamicParameter = new AsciiParameters() { PixelPerCharacter = 5 }; // act Bitmap result = new Bitmap(processor.ProcessImage(factory)); Bitmap result2 = new Bitmap(processor2.ProcessImage(factory)); result2.Save(string.Format("{0}/{1}_ascii_pixel_per_character2.jpg", Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file)), ImageFormat.Jpeg); // assert result.Equals(result2).Should().BeFalse("because different parameters should yield different images"); } } }
public IAlgo create() { IAlgo algoritme = null; switch (this.algo) { case "simple": algoritme = new Simple(); break; case "ascii": algoritme = new Ascii(); break; case "shift": algoritme = new Shift(); break; default: break; } if (algoritme == null) { return(null); } return(algoritme); }
/// <summary> /// Called when type specific data need to be loaded. /// </summary> protected override void LoadData() { base.LoadData(); _requestNameBytes = ReadBinary(); _requestName = Ascii.GetString(_requestNameBytes, 0, _requestNameBytes.Length); RequestData = ReadBytes(); }
public override byte[] EncodeValue(ScalarValue value) { #warning BUG? This used to format all values using "d-MMM-yy h:mm:ss tt" format, and now it uses constructor parameter instead return (Ascii.Encode( new StringValue( (((DateValue)value).Value).ToString(_format, _formatter)))); }
public void OnStartLine(Http.Method method, Http.Version version, ReadOnlySpan <byte> target, ReadOnlySpan <byte> path, ReadOnlySpan <byte> query, ReadOnlySpan <byte> customMethod, bool pathEncoded) { Method = method; Version = version; Path = Ascii.ToUtf16String(path); Query = Ascii.ToUtf16String(query); Target = Ascii.ToUtf16String(target); }
/// <summary> /// Initializes a new instance of the <see cref="RequestMessageHost"/> class. /// </summary> /// <param name="serviceName">Name of the service.</param> /// <param name="username">Authentication username.</param> /// <param name="publicKeyAlgorithm">The public key algorithm.</param> /// <param name="publicHostKey">The public host key.</param> /// <param name="clientHostName">Name of the client host.</param> /// <param name="clientUsername">The client username.</param> /// <param name="signature">The signature.</param> public RequestMessageHost(ServiceName serviceName, string username, string publicKeyAlgorithm, byte[] publicHostKey, string clientHostName, string clientUsername, byte[] signature) : base(serviceName, username, "hostbased") { PublicKeyAlgorithm = Ascii.GetBytes(publicKeyAlgorithm); PublicHostKey = publicHostKey; ClientHostName = Ascii.GetBytes(clientHostName); ClientUsername = Utf8.GetBytes(clientUsername); Signature = signature; }
public void OnStartLine(Http.Method method, Http.Version version, ReadOnlySpan <byte> target, ReadOnlySpan <byte> path, ReadOnlySpan <byte> query, ReadOnlySpan <byte> customMethod, bool pathEncoded) { Method = method != Http.Method.Custom ? method.ToString().ToUpper() : Ascii.ToUtf16String(customMethod); Version = ToString(version); RawTarget = Ascii.ToUtf16String(target); RawPath = Ascii.ToUtf16String(path); Query = Ascii.ToUtf16String(query); PathEncoded = pathEncoded; }
public void Ascii_Contains_Valid_Value(Ascii ascii, int expectedHex, char? expectedChar) { Assert.That((int)ascii, Is.EqualTo(expectedHex)); if (expectedChar != null) { Assert.That((char)ascii, Is.EqualTo(expectedChar)); } }
public void Ascii_Contains_Valid_Value(Ascii ascii, int expectedHex, char?expectedChar) { Assert.That((int)ascii, Is.EqualTo(expectedHex)); if (expectedChar != null) { Assert.That((char)ascii, Is.EqualTo(expectedChar)); } }
[InlineData('\u0080', '\u0080' + 32)] // Outside of ASCII range public void AsciiIgnoreCaseEquals_ReturnsFalse(char x, char y) { // Arrange // Act var result = Ascii.AsciiIgnoreCaseEquals(x, y); // Assert Assert.False(result); }
public void IsAscii_ReturnsFalseForNonAscii() { // Arrange var text = "abcd\u0080"; // Act var result = Ascii.IsAscii(text); // Assert Assert.False(result); }
public void IsAscii_ReturnsTrueForAscii() { // Arrange var text = "abcd\u007F"; // Act var result = Ascii.IsAscii(text); // Assert Assert.True(result); }
public void Verify_Calculator_Sums_Ascii() { // Arrange var text = "iffy"; // Act var result = Ascii.Sum(text); // Assert Assert.AreEqual(220, result); }
public void Verify_Calculator_01() { // Arrange var text = "Work."; // Act var result = Ascii.Sum(text); // Assert Assert.AreEqual(197, result); }
public void Verify_Calculator_On_Quote() { // Arrange var text = "Work hard to improve. Success is also easy to handle: You've solved the wrong problem. Work hard to improve."; // Act var result = Ascii.Sum(text); // Assert Assert.AreEqual(2593, result); }
public override int GetHashCode() { int hash = 17; hash += 23 * Ascii.GetHashCode(); hash += 23 * Integer.GetHashCode(); hash += 23 * Boolean.GetHashCode(); hash += 23 * Unicode.GetHashCode(); hash += 23 * Single.GetHashCode(); return(hash); }
public void UnsafeAsciiIgnoreCaseEquals_ReturnsFalse(string x, string y, int length) { // Arrange var spanX = x.AsSpan(); var spanY = y.AsSpan(); // Act var result = Ascii.AsciiIgnoreCaseEquals(spanX, spanY, length); // Assert Assert.False(result); }
/// <summary> /// Called when type specific data need to be loaded. /// </summary> protected override void LoadData() { base.LoadData(); #if true //old TUNING _requestNameBytes = ReadBinary(); _requestName = Ascii.GetString(_requestNameBytes, 0, _requestNameBytes.Length); #else RequestName = ReadAsciiString(); #endif RequestData = ReadBytes(); }
public void AsciiToUtf16StringWorksOnAllAsciiChars() { for (int index = 0; index < 100; index++) { var encoded = (Span <byte>) new byte[100]; for (int encodedByte = 0; encodedByte < 128; encodedByte++) { encoded[index] = (byte)encodedByte; var result = Ascii.ToUtf16String(encoded); } } }
private void AddOneRowItem(int index) { if (index == 0) { //FormHelper.NewWuLiaoRow(); //FormHelper.SendTab(); FormHelper.MoveToWuLiaoListDefaultRow(); } else { FormHelper.MoveToNextWuLiaoRow(); } var wuliaoBianMa = "1281000002"; SendKeys.SendWait(wuliaoBianMa); Thread.Sleep(50); FormHelper.SendTab(); Thread.Sleep(50); FormHelper.SendBackTab(); Thread.Sleep(500); FormHelper.EditWuLiaoInForm(); FormHelper.SetFocusOnHangHaoEditBox(); Thread.Sleep(500); FormHelper.SendTab(); FormHelper.SendTab(); FormHelper.SendTab(); //SendKeys.SendWait("1"); Thread.Sleep(500); Mouse.keybd_event(Ascii.GetAscii('1'), 0, 0, 0); Thread.Sleep(500); FormHelper.SendTab(); Thread.Sleep(500); Mouse.keybd_event(Ascii.GetAscii('1'), 0, 0, 0); Thread.Sleep(500); FormHelper.SendTab(); Thread.Sleep(500); FormHelper.CloseWuLiaoItemForm(); }
/// <summary> /// Initializes a new instance of the <see cref="Currency" /> class for the specified code. /// </summary> /// <param name="code">A string that contains the three-letter identifier defined in ISO 4217.</param> /// <param name="minorUnits">The value of a unit expressed in minor units. If there are no /// minor units, use null instead.</param> internal Currency(string code, short?minorUnits) { Debug.Assert(code != null); // A currency code MUST be composed of exactly 3 letters. Debug.Assert(code.Length == 3); // A currency code MUST only contain uppercase ASCII letters. Debug.Assert(Ascii.IsUpperLetter(code)); Debug.Assert(!minorUnits.HasValue || minorUnits >= 0); Code = code; MinorUnits = minorUnits; }
public override ScalarValue Decode(Stream inStream) { ScalarValue subtractionLength = NullableInteger.Decode(inStream); if (subtractionLength == null) { return(null); } ScalarValue difference = Ascii.Decode(inStream); return(new TwinValue(subtractionLength, difference)); }
public bool Equals(TestObject other) { if (other == null) { return(false); } return(Ascii.Equals(other.Ascii) && Integer.Equals(other.Integer) && Boolean.Equals(other.Boolean) && Unicode.Equals(other.Unicode) && Single.Equals(other.Single)); }