Нашли или выдавили из себя код, который нельзя назвать нормальным,
на который без улыбки не взглянешь?
Не торопитесь его удалять или рефакторить, — запостите его на
говнокод.ру, посмеёмся вместе!
import java.security.*
var keys = KeyPairGenerator.getInstance("EC").generateKeyPair();
var blankSignature = new byte[64]; // zero bytes
var sig = Signature.getInstance("SHA256WithECDSAInP1363Format");
sig.initVerify(keys.getPublic());
sig.update("Hello, World".getBytes()); // anything
sig.verify(blankSignature); // true
Сказка о том, как джавушки переписали код с небезопасного языка на безопасный и помножили проверку подписей на ноль (в прямом смысле).
import java.util.InputMismatchException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
try {
System.out.println("How many characters will be in the password? (1-256):");
short length = scanner.nextShort();
if (length > 256) {
System.out.println("Password can't be longer than 256 characters!");
} else if (length < 1) {
System.out.println("Password can't be less than 1 character long!");
} else {
System.out.println("How many passwords will be generated? (1-32)");
byte amount = scanner.nextByte();
if (amount > 32) {
System.out.println("You can't generate more than 32 passwords!");
} else if (amount < 1) {
System.out.println("You can't generate less than 1 password!");
} else {
for (byte i = 0; i < amount; i++) {
System.out.println("\n" + PasswordGenerator.generate(length));
}
}
}
} catch (InputMismatchException e) {
System.out.println("Input error!");
}
}
}
package com.company;
import java.util.Scanner;
public class Main {
public static void main (String [] args) {
Scanner num = new Scanner(System.in);
int first;
System.out.print("Enter first num: ");
first = num.nextInt();
if (first==10)
System.out.print("Num is 10");
}
}
public class Spot {
private Piece piece;
private int x;
private int y;
public Spot(int x, int y, Piece piece)
{
this.setPiece(piece);
this.setX(x);
this.setY(y);
}
public Piece getPiece() // метод возвращает объект фигуру
{
return this.piece;
}
public void setPiece(Piece p)
{
this.piece = p;
}
public int getX()
{
return this.x;
}
public void setX(int x)
{
this.x = x;
}
public int getY()
{
return this.y;
}
public void setY(int y)
{
this.y = y;
}
}
Дизайн шахматной игры Эти виды вопросов задаются на интервью, чтобы судить о навыке объектно ориентированного дизайна кандидата. Итак, прежде всего, мы должны подумать о классах. https://habr.com/ru/post/660003/